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

/**
 * showToast/*  www  .  j  a  v a  2  s.  c  o m*/
 * @param context
 * @param message
 * @param duration    LENGTH_SHORT,LENGTH_LONG
 */
public static void showToastTips(Context context, String message, int duration) {
    if (!TextUtils.isEmpty(message)) {
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
    }
}

From source file:Main.java

public static void showToast(Context context, String str, int durationType) {
    if (!str.equals("")) {
        Toast.makeText(context, str, durationType).show();
    }//from w  w  w  .j a  va  2  s.co m
}

From source file:Main.java

public static boolean isValidSignUp(String username, String password, String confirmPassword,
        Context thisActivtiy) {//  w  w w. j  ava 2  s.  c o m
    //One of the field is left blank
    if (username.equals("") || password.equals("") || confirmPassword.equals("")) {
        Toast.makeText(thisActivtiy, "Please fill in all fields.", Toast.LENGTH_SHORT).show();
        return false;
    }

    //The info is not of the right format
    //Need to finish this later
    else if (false) {
        Toast.makeText(thisActivtiy, "Please fill in all fields.", Toast.LENGTH_SHORT).show();
        return false;
    }

    //The passwords entered do not match
    else if (!password.equals(confirmPassword)) {
        Toast.makeText(thisActivtiy, "The passwords you entered do not match.", Toast.LENGTH_SHORT).show();
        return false;
    }

    else
        return true;
}

From source file:Main.java

public static void toast(final String s, final Context context) {

    Handler handler = new Handler(Looper.getMainLooper());

    handler.post(new Runnable() {

        @Override/*from   www . j a  v a  2s .c o m*/
        public void run() {
            Toast.makeText(context, s, Toast.LENGTH_SHORT).show();

        }
    });
}

From source file:Main.java

private static void showToast(final Context context, final int resId) {
    Handler handler = new Handler(Looper.getMainLooper());

    handler.post(new Runnable() {

        @Override// w  ww.  j  a va 2  s.  co m
        public void run() {
            Toast.makeText(context, resId, Toast.LENGTH_LONG).show();

        }
    });
}

From source file:Main.java

private synchronized static void globalToast(Context context, String tip, int duration) {
    if (toast != null) {
        toast.setText(tip);//from w w  w. j a  va2  s. co  m
        toast.setDuration(duration);
    } else {
        toast = Toast.makeText(context, tip, duration);
    }
    toast.show();
}

From source file:Main.java

private static void showToast(Context context, CharSequence text) {
    Toast.makeText(context, text, Toast.LENGTH_LONG).show();
}

From source file:Main.java

public static void showToast(Context context, String msg, int duration) {
    // if (mToast != null) {
    // mToast.cancel();
    // }//from   w w w  .j av a  2  s .c o m
    // mToast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
    if (mToast == null) {
        mToast = Toast.makeText(context, msg, duration);
    } else {
        mToast.setText(msg);
    }
    mToast.show();
}

From source file:Main.java

public static void showShort(Context context, int message) {
    if (isShow)/*w  ww  .ja v  a 2s. c o m*/
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static void showToast(final String text) {
    handler.post(new Runnable() {

        @Override//from  www.j  a  v a2 s. c o  m
        public void run() {
            Toast.makeText(context, text, Toast.LENGTH_SHORT).show();

        }
    });

}