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
/** * Show toast message./*w ww.j a v a2s.c o m*/ * * @param context Context * @param message Text to display */ public static void ShowMessage(Context context, String message) { if (context != null) { if (TOAST != null) { TOAST.cancel(); } Toast newToast = Toast.makeText(context, message, message.length() < 15 ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG); TextView textView = (TextView) newToast.getView().findViewById(android.R.id.message); textView.setGravity(Gravity.CENTER); textView.setSingleLine(false); newToast.show(); TOAST = newToast; } }
From source file:Main.java
public static void showSingleToast(Context ctx, @StringRes int msgID, int duration) { String msg = ctx.getString(msgID); int showDuration = duration <= Toast.LENGTH_SHORT ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT; if (null == toast) { toast = Toast.makeText(ctx.getApplicationContext(), msgID, showDuration); toast.show();//from w w w .java2s.co m oneTime = System.currentTimeMillis(); } else { twoTime = System.currentTimeMillis(); if (msg.equals(oldMsg)) { if (twoTime - oneTime > showDuration) { toast.show(); } } else { oldMsg = msg; toast.setText(msg); toast.show(); } } oneTime = twoTime; }
From source file:Main.java
/** * // w w w . j av a2 s. co m * @param context * @param text * @param gravity * @param xOffset * @param yOffset */ public static void showLong(Context context, CharSequence text, int gravity, int xOffset, int yOffset) { Toast t = Toast.makeText(context, text, Toast.LENGTH_LONG); t.setGravity(gravity, xOffset, yOffset); t.show(); }
From source file:Main.java
/** * Method to get more apps// w w w . j a va 2s .c om * * @param context * @param publisherName */ public static void getMoreApps(Context context, String publisherName) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:" + publisherName)); if (isIntentAvailable(context, intent)) { context.startActivity(intent); } else { Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show(); } }
From source file:Main.java
public static void showToastLong(Context ctx, String msg) { Toast.makeText(ctx, msg, Toast.LENGTH_LONG).show(); }
From source file:Main.java
/** * @param context The context the toast is displayed. Can be application context. * @param text The text contained in the toast * @param shortTime Whether to display toast with shorter duration. *//*from ww w . ja v a 2s . c om*/ public static void createToast(Context context, String text, boolean shortTime) { int duration = (shortTime) ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG; Toast.makeText(context, text, duration).show(); }
From source file:Main.java
public static void toast(Context context, CharSequence message) { Toast.makeText(context, message, Toast.LENGTH_LONG).show(); }
From source file:Main.java
private static void saveActivity(Activity activity, Class<? extends Activity> clazz) { FileOutputStream fos = null;/*from w w w. j a va 2 s . c o m*/ try { fos = activity.openFileOutput(FILENAME, Activity.MODE_PRIVATE); fos.write(clazz.getName().getBytes()); } catch (Exception e) { Toast.makeText(activity, "saveActivity: " + e, Toast.LENGTH_LONG).show(); } finally { if (null != fos) try { fos.close(); } catch (Exception e) { } } }
From source file:Main.java
static void showLongToastMessage(Context context, String message) { Toast.makeText(context, message, Toast.LENGTH_LONG).show(); }
From source file:Main.java
public static void showToast(String message, Context context) { showToast(message, context, Toast.LENGTH_LONG); }