List of usage examples for android.widget Toast show
public void show()
From source file:com.pdftron.pdf.utils.Utils.java
public static void showToast(Context context, int stringId, int duration) { if (context != null) { Toast toast = Toast.makeText(context, stringId, duration); if (Utils.isRtlLayout(context)) { toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL); }/*from w ww. jav a 2 s.c o m*/ toast.show(); } }
From source file:Main.java
/** * Internal helper method to show the cheat sheet toast. *//*from w w w.ja v a2 s . c o m*/ private static boolean show(View view, CharSequence text) { if (TextUtils.isEmpty(text)) { return false; } final int[] screenPos = new int[2]; // origin is device display final Rect displayFrame = new Rect(); // includes decorations (e.g. status bar) view.getLocationOnScreen(screenPos); view.getWindowVisibleDisplayFrame(displayFrame); final Context context = view.getContext(); final int viewWidth = view.getWidth(); final int viewHeight = view.getHeight(); final int viewCenterX = screenPos[0] + viewWidth / 2; final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; final int estimatedToastHeight = (int) (ESTIMATED_TOAST_HEIGHT_DIPS * context.getResources().getDisplayMetrics().density); Toast cheatSheet = Toast.makeText(context, text, Toast.LENGTH_SHORT); boolean showBelow = screenPos[1] < estimatedToastHeight; if (showBelow) { // Show below // Offsets are after decorations (e.g. status bar) are factored in cheatSheet.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, viewCenterX - screenWidth / 2, screenPos[1] - displayFrame.top + viewHeight); } else { // Show above // Offsets are after decorations (e.g. status bar) are factored in // NOTE: We can't use Gravity.BOTTOM because when the keyboard is up // its height isn't factored in. cheatSheet.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, viewCenterX - screenWidth / 2, screenPos[1] - displayFrame.top - estimatedToastHeight); } cheatSheet.show(); return true; }
From source file:net.ben.subsonic.androidapp.util.Util.java
public static void toast(Context context, int messageId, boolean shortDuration) { Toast toast = Toast.makeText(context, messageId, shortDuration ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }
From source file:com.provision.alarmemi.paper.fragments.SetAlarmFragment.java
public static void popAlarmSetToast(Context context, long timeInMillis) { String toastText = Alarms.formatToast(context, timeInMillis); Toast toast = Toast.makeText(context, toastText, Toast.LENGTH_LONG); ToastMaster.setToast(toast);// ww w . j a v a 2 s . c o m toast.show(); }
From source file:com.pdftron.pdf.utils.Utils.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static void showToast(Context context, String string) { if (context != null) { Toast toast = Toast.makeText(context, string, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); if (Utils.isRtlLayout(context)) { toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL); }/* ww w . j a va 2s . co m*/ toast.show(); return; } }
From source file:com.pdftron.pdf.utils.Utils.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static void showToast(Context context, int stringId) { if (context != null) { Toast toast = Toast.makeText(context, stringId, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); if (Utils.isRtlLayout(context)) { toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL); }//w w w. j a va2s . c om toast.show(); } }
From source file:com.pdftron.pdf.utils.Utils.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static Toast showToast(Context context, Toast toast, String text, int duration) { if (toast != null) { toast.cancel();//from w ww. j a v a2 s . co m } toast = Toast.makeText(context, text, duration); if (Utils.isRtlLayout(context)) { toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL); } toast.show(); return toast; }
From source file:com.pdftron.pdf.utils.Utils.java
public static Toast showToast(Context context, Toast toast, int stringId, int duration) { if (toast != null) { toast.cancel();/*from w w w . j a v a2s .co m*/ } toast = Toast.makeText(context, stringId, duration); if (Utils.isRtlLayout(context)) { toast.getView().setTextDirection(View.TEXT_DIRECTION_RTL); } toast.show(); return toast; }
From source file:com.farmerbb.secondscreen.util.U.java
public static void showToastLong(Context context, int message) { Toast toast = Toast.makeText(context, context.getResources().getString(message), Toast.LENGTH_LONG); toast.show(); }
From source file:com.farmerbb.secondscreen.util.U.java
public static void showToast(Context context, int message) { Toast toast = Toast.makeText(context, context.getResources().getString(message), Toast.LENGTH_SHORT); toast.show(); }