List of usage examples for android.widget Toast LENGTH_SHORT
int LENGTH_SHORT
To view the source code for android.widget Toast LENGTH_SHORT.
Click Source Link
From source file:Main.java
public static void copyToClipBoard(Context context, String text, String success) { ClipData clipData = ClipData.newPlainText("meizhi_copy", text); ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); manager.setPrimaryClip(clipData);//from w w w . j av a 2 s.c o m Toast.makeText(context, success, Toast.LENGTH_SHORT).show(); }
From source file:Main.java
/** * Show message.//w ww. j a va 2 s . c om * * @param context * the context * @param msg * the msg */ public static void showMessage(Context context, CharSequence msg) { Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); }
From source file:Main.java
private static boolean showToolTip(View view, CharSequence text) { if (TextUtils.isEmpty(text)) { return false; }//w ww .j a va 2 s .c o m 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:Main.java
public static void setFlashMode(Camera mCamera, Context item, int type) { Camera.Parameters params = mCamera.getParameters(); List<String> FlashModes = params.getSupportedFlashModes(); switch (type) { case 0://from www. j a v a 2 s.c om if (FlashModes.contains(Camera.Parameters.FLASH_MODE_AUTO)) params.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO); else Toast.makeText(item, "Auto Mode not supported", Toast.LENGTH_SHORT).show(); break; case 1: if (FlashModes.contains(Camera.Parameters.FLASH_MODE_OFF)) params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF); else Toast.makeText(item, "Off Mode not supported", Toast.LENGTH_SHORT).show(); break; case 2: if (FlashModes.contains(Camera.Parameters.FLASH_MODE_ON)) params.setFlashMode(Camera.Parameters.FLASH_MODE_ON); else Toast.makeText(item, "On Mode not supported", Toast.LENGTH_SHORT).show(); break; case 3: if (FlashModes.contains(Camera.Parameters.FLASH_MODE_RED_EYE)) params.setFlashMode(Camera.Parameters.FLASH_MODE_RED_EYE); else Toast.makeText(item, "Red Eye Mode not supported", Toast.LENGTH_SHORT).show(); break; case 4: if (FlashModes.contains(Camera.Parameters.FLASH_MODE_TORCH)) params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); else Toast.makeText(item, "Torch Mode not supported", Toast.LENGTH_SHORT).show(); break; } mCamera.setParameters(params); }
From source file:Main.java
/** * Shows toast message with given message shortly. * * @param text message to show/* ww w . ja v a 2 s .c om*/ * @see #showLong(android.content.Context, CharSequence) */ @NonNull public static Toast showShort(@NonNull Context context, @NonNull CharSequence text) { return show(context, text, Toast.LENGTH_SHORT); }
From source file:Main.java
public static void setFocusMode(Camera mCamera, Context item, int type) { Camera.Parameters params = mCamera.getParameters(); List<String> FocusModes = params.getSupportedFocusModes(); switch (type) { case 0:// w ww . jav a 2 s . c o m if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO)) params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); else Toast.makeText(item, "Auto Mode not supported", Toast.LENGTH_SHORT).show(); break; case 1: if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); else Toast.makeText(item, "Continuous Mode not supported", Toast.LENGTH_SHORT).show(); break; case 2: if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_EDOF)) params.setFocusMode(Camera.Parameters.FOCUS_MODE_EDOF); else Toast.makeText(item, "EDOF Mode not supported", Toast.LENGTH_SHORT).show(); break; case 3: if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_FIXED)) params.setFocusMode(Camera.Parameters.FOCUS_MODE_FIXED); else Toast.makeText(item, "Fixed Mode not supported", Toast.LENGTH_SHORT).show(); break; case 4: if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_INFINITY)) params.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY); else Toast.makeText(item, "Infinity Mode not supported", Toast.LENGTH_SHORT).show(); break; case 5: if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_MACRO)) params.setFocusMode(Camera.Parameters.FOCUS_MODE_MACRO); else Toast.makeText(item, "Macro Mode not supported", Toast.LENGTH_SHORT).show(); break; } mCamera.setParameters(params); }
From source file:Main.java
/** * Copy a text to the clipboard./*from w ww .ja v a2s . co m*/ * @param context The current context. * @param text The text to copy. * @param toastMessage The message to show in a Toast notification. If empty or null, does not display notification. */ public static void copyTextToClipboard(Context context, String text, String toastMessage) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Activity.CLIPBOARD_SERVICE); clipboard.setText(text); if ((toastMessage != null) && (toastMessage.length() > 0)) { Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
public static AlertDialog showDownloadDialog(final Context ctx) { AlertDialog.Builder downloadDialog = new AlertDialog.Builder(ctx); downloadDialog.setTitle("Layar is not available"); downloadDialog.setMessage("Do you want to download it from the market?"); downloadDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override/*w w w . j ava 2 s. com*/ public void onClick(DialogInterface dialogInterface, int i) { Uri uri = Uri.parse("market://details?id=com.layar"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); try { ctx.startActivity(intent); } catch (ActivityNotFoundException anfe) { Toast.makeText(ctx, "Market not installed", Toast.LENGTH_SHORT).show(); } } }); downloadDialog.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }); return downloadDialog.show(); }
From source file:Main.java
/** * Copy a text to the clipboard./*w ww . j av a 2 s. co m*/ * * @param context * The current context. * @param text * The text to copy. * @param toastMessage * The message to show in a Toast notification. If empty or null, * does not display notification. */ public static void copyTextToClipboard(Context context, String text, String toastMessage) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setText(text); if ((toastMessage != null) && (toastMessage.length() > 0)) { Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show(); } }
From source file:Main.java
/** * Copy a text to the clipboard.// w ww .j a v a 2s. c o m * @param context The current context. * @param text The text to copy. * @param toastMessage The message to show in a Toast notification. If empty or null, does not display notification. */ public static void copyTextToClipboard(Context context, String text, String toastMessage) { ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); clipboard.setPrimaryClip(ClipData.newPlainText(text, text)); if ((toastMessage != null) && (toastMessage.length() > 0)) { Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show(); } }