List of usage examples for android.widget Toast LENGTH_LONG
int LENGTH_LONG
To view the source code for android.widget Toast LENGTH_LONG.
Click Source Link
From source file:Main.java
public static void showHint(final Context c, String hintText, boolean makeItAQuickOne) { int duration = makeItAQuickOne ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG; Toast t = Toast.makeText(c, hintText, duration); t.setGravity(Gravity.CENTER_VERTICAL, 0, 0); t.show();/*from ww w . j a v a 2s .com*/ }
From source file:Main.java
/** Makes a long toast */ public static void longToast(String message, Context context) { CharSequence text = message;//from www . j a va 2 s . c om int duration = Toast.LENGTH_LONG; Toast toast = Toast.makeText(context, text, duration); toast.show(); }
From source file:Main.java
public static void showMessageText(final Activity activity, final String text) { activity.runOnUiThread(new Runnable() { public void run() { Toast.makeText(activity, text, Toast.LENGTH_LONG).show(); }/*w ww. ja v a 2s . c om*/ }); }
From source file:Main.java
public static boolean isExternalStoragePresent(Context context) { boolean externalStorageAvailable; boolean externalStorageWritable; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { // We can read and write the media externalStorageAvailable = externalStorageWritable = true; } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { // We can only read the media externalStorageAvailable = true; externalStorageWritable = false; } else {//from w w w.ja v a2 s. co m // Something else is wrong. It may be one of many other states, but all we need to know is we can neither read nor write externalStorageAvailable = externalStorageWritable = false; } if (!((externalStorageAvailable) && (externalStorageWritable))) { Toast.makeText(context, "SD card not present", Toast.LENGTH_LONG).show(); } return (externalStorageAvailable) && (externalStorageWritable); }
From source file:Main.java
/** * Toast dialog with string/*from w ww . j a va 2s . c om*/ */ public static void showToast(final String message, final Activity activity) { final Toast toast = Toast.makeText(activity, message, Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show(); }
From source file:Main.java
/** * Display Toast with the input message/*from w ww . j ava 2 s . com*/ * @param activity - {@link Activity} instance * @param message - Message to be displayed in Toast */ public static void showToast(Activity activity, String message) { Toast.makeText(activity, message, Toast.LENGTH_LONG).show(); }
From source file:Main.java
public static void showToast(Context context, View view) { Toast toast = new Toast(context); toast.setView(view);/*from ww w . j a va 2 s .c o m*/ toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.show(); }
From source file:Main.java
/** * Shows an error alert dialog with the given message. * /*from w ww .java 2 s .c om*/ * @param activity activity * @param message message to show or {@code null} for none */ public static void showError(final Activity activity, String message) { final String errorMessage = message == null ? "Error" : "[Error ] " + message; activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, errorMessage, Toast.LENGTH_LONG).show(); } }); }
From source file:Main.java
public static void showToast(final Activity activity, final String msg) { Log.i(TAG, "Show Toast: " + msg); if (activity == null) { return;/*ww w. j a va 2s .c o m*/ } activity.runOnUiThread(new Runnable() { @Override public void run() { try { Toast toast = Toast.makeText(activity, msg, Toast.LENGTH_LONG); toast.show(); } catch (Throwable e) { Log.e(TAG, "error: " + e, e); } } }); }
From source file:Main.java
public static void show(Context context, CharSequence text) { if (!TextUtils.isEmpty(text)) { if (text.length() < 10) { Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); } else {/*from w w w. ja va2 s . com*/ Toast.makeText(context, text, Toast.LENGTH_LONG).show(); } } }