Example usage for android.widget Toast makeText

List of usage examples for android.widget Toast makeText

Introduction

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

Prototype

public static Toast makeText(Context context, @StringRes int resId, @Duration int duration)
        throws Resources.NotFoundException 

Source Link

Document

Make a standard toast that just contains a text view with the text from a resource.

Usage

From source file:Main.java

public static void toastMsg(Context context, String msg, int duration) {
    if (context != null)
        Toast.makeText(context, msg, duration).show();
}

From source file:Main.java

public static void showToast(Context context, String text) {
    Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*from  ww  w. j  a v  a2  s. com*/
}

From source file:Main.java

public static void showToastShort(Context context, String message) {
    Toast toast = Toast.makeText(context.getApplicationContext(), message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*from w  w w. j a va 2s.c o m*/
}

From source file:Main.java

public static void showMessage(Context context, int messageId) {
    Toast.makeText(context, messageId, Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void centerToast(Context context, String message) {
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 0);
    toast.show();/*from   w w w .j  av a  2s  .  com*/
}

From source file:Main.java

public static void showLongToast(Context context, String string) {
    Toast toast = Toast.makeText(context, string, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();// w  ww  .  ja  v a2 s  .c  o m
}

From source file:Main.java

public static void showToast(Context ctx, String message) {
    Toast t = Toast.makeText(ctx, message, Toast.LENGTH_SHORT);
    t.show();
}

From source file:Main.java

public static void showLongToast(Context mContext, CharSequence text) {
    Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void toastInMiddle(Context context, String message) {
    Toast toast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();/*from  ww  w .j  a v a 2  s. co  m*/
}

From source file:Main.java

public static void openToast(Context context, String str) {
    //Looper.prepare();
    Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
    Looper.loop();/*from w  ww  .  ja  va 2s .c  o  m*/
}