Example usage for android.widget Toast LENGTH_SHORT

List of usage examples for android.widget Toast LENGTH_SHORT

Introduction

In this page you can find the example usage for android.widget Toast LENGTH_SHORT.

Prototype

int LENGTH_SHORT

To view the source code for android.widget Toast LENGTH_SHORT.

Click Source Link

Document

Show the view or text notification for a short period of time.

Usage

From source file:Main.java

public static void showToast(Context ctx, int id) {

    Context context = ctx;/*from w  w w .j ava 2 s  .co m*/
    int duration = Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(context, context.getResources().getString(id), duration);
    toast.show();
}

From source file:Main.java

public static AlertDialog AlertDialogSingle(final Context context, String Title, String Message,
        String ButtonName) {// w  w w .  j a va2s  .com
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();

    // Setting Dialog Title
    alertDialog.setTitle(Title);

    // Setting Dialog Message
    alertDialog.setMessage(Message);

    // Setting OK Button
    alertDialog.setButton(ButtonName, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            Toast.makeText(context, "You clicked on OK", Toast.LENGTH_SHORT).show();
            dialog.dismiss();
        }
    });

    // Showing Alert Message
    return alertDialog;
}

From source file:Main.java

public static void show(final Activity activity, final String message) {
    activity.runOnUiThread(new Runnable() {
        public void run() {
            Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
        }/*from www.j  ava 2  s .co  m*/
    });
}

From source file:Main.java

public static void showShortToast(final Context context, final String message) {
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
    toast.show();// w  w  w.ja v  a 2  s.  com
}

From source file:Main.java

public static void showTip(Context context, int resId, boolean isInter) {
    if (null == showToast) {
        showToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
    } else {// w  ww. ja v a 2  s .  c o m
        if (isInter) {
            showToast.cancel();
            showToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
        } else {
            showToast.setText(resId);
        }
    }
    showToast.setGravity(Gravity.BOTTOM, 0, 0);
    showToast.show();
}

From source file:Main.java

public static void toastShow(final Activity activity, final String message) {
    activity.runOnUiThread(new Runnable() {
        public void run() {
            Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
        }/*from w ww . jav  a2  s .  c  o  m*/
    });
}

From source file:Main.java

public static void showLongToast(Context context, String s) {
    Toast.makeText(context, s, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showToastShort(Context ctx, int rid) {
    Toast.makeText(ctx, ctx.getString(rid), Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showToast(final Context mContext, final String text) {
    sharedHandler(mContext).post(() -> {
        if (toast != null) {
            toast.setText(text);/*  w w w  .  j  av a 2 s  .c om*/
            toast.setDuration(Toast.LENGTH_SHORT);
        } else {
            toast = Toast.makeText(mContext.getApplicationContext(), text, Toast.LENGTH_SHORT);
        }
        toast.show();
    });
}

From source file:Main.java

public static void showToast(CharSequence msg, Context context) {
    showToast(msg, Toast.LENGTH_SHORT, context);
}