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 show(Context context, String info) {
    if (TextUtils.isEmpty(info))
        return;//w w  w .  j  a  v a 2  s .  c  o  m
    Toast.makeText(context, info, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showToast(Context context, CharSequence text, int duration) {
    if (mToast == null) {
        mToast = Toast.makeText(context, text, duration);
    } else {/* w w  w  .ja va2s .c  o  m*/
        mToast.setText(text);
        mToast.setDuration(duration);
    }
    mToast.show();
}

From source file:Main.java

public static boolean isValidPost(String post, Context thisActivtiy) {
    //If no words typed
    if (post.equals("")) {
        Toast.makeText(thisActivtiy, "Please enter in a post.", Toast.LENGTH_SHORT).show();
        return false;
    }/*www .  j a va  2  s.  c om*/
    //The info is not of the right format
    else if (false) {
        Toast.makeText(thisActivtiy, ".", Toast.LENGTH_SHORT).show();
        return false;
    }
    //Filter it and it is bad!
    else if (false) {
        Toast.makeText(thisActivtiy, ".", Toast.LENGTH_SHORT).show();
        return false;
    }
    //Everything is good and the info can be used to create a new account
    else
        return true;
}

From source file:Main.java

/**
 * @param message/*from  w  w w.j av a 2s . c  om*/
 */
public static void showToast(int message, Toast mToast, Context context) {
    if (mToast == null) {
        mToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
    }
    mToast.setText(context.getString(message));
    mToast.show();
}

From source file:Main.java

public static void showToast(String message, Context context) {
    int duration = Toast.LENGTH_SHORT;
    Toast toast = Toast.makeText(context, message, duration);
    toast.show();//from  w w  w  .  j av a 2 s .c  o m
}

From source file:Main.java

private static void showToast(Context context, @StringRes int resId) {
    Toast.makeText(context, resId, Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void show(String msg, Context context) {
    if (toast == null) {
        toast = Toast.makeText(context, msg, Toast.LENGTH_LONG);
    }/*from  w w  w  .  ja v  a  2  s .c o  m*/
    toast.setText(msg);
    toast.show();
}

From source file:Main.java

public static void showCenterShortToast(String text, Context ctx) {

    int duration = Toast.LENGTH_SHORT;

    Toast toast = Toast.makeText(ctx, text, duration);

    toast.setGravity(Gravity.CENTER, 0, 0);

    toast.show();//from w w  w .  j a  va  2 s . co  m

}

From source file:Main.java

public static void showMessage(final Activity activity, final String message) {
    activity.runOnUiThread(new Runnable() {
        public void run() {
            Toast.makeText(activity, message, Toast.LENGTH_LONG).show();
        }/*from  ww w.j av  a 2 s .co  m*/
    });
}

From source file:Main.java

public static void showToast(final Context context, final String message) {
    if (mToast == null) {
        mToast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
    } else {//from w  w w . jav a 2  s  . co  m
        mToast.setText(message);
        mToast.setDuration(Toast.LENGTH_SHORT);
    }
    mToast.show();
}