List of usage examples for android.widget Toast setGravity
public void setGravity(int gravity, int xOffset, int yOffset)
From source file:com.streaming.sweetplayer.utils.Utils.java
/** * Function to show a message to the user. * It looks good to center the message./*from w w w . j a v a 2s . c om*/ * * @param context Context * @param message CharSequence */ public static void showUserMessage(Context context, CharSequence message) { Toast playingMessage = Toast.makeText(context, message, Toast.LENGTH_LONG); playingMessage.setGravity(Gravity.CENTER, 0, 0); playingMessage.show(); }
From source file:com.github.rutvijkumar.twittfuse.Util.java
public static void showNetworkUnavailable(Activity activity) { LayoutInflater inflater = activity.getLayoutInflater(); View view = inflater.inflate(R.layout.network_not_available, (ViewGroup) activity.findViewById(R.id.nwunavailable)); Toast toast = new Toast(activity); toast.setView(view);//from w ww . j ava 2s. c om toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.show(); }
From source file:de.baumann.hhsmoodle.helper.helper_main.java
public static void makeToast(Activity activity, String Text) { LayoutInflater inflater = activity.getLayoutInflater(); View toastLayout = inflater.inflate(R.layout.toast, (ViewGroup) activity.findViewById(R.id.toast_root_view)); TextView header = (TextView) toastLayout.findViewById(R.id.toast_message); header.setText(Text);/*from w ww . jav a 2 s. c o m*/ Toast toast = new Toast(activity.getApplicationContext()); toast.setGravity(Gravity.FILL_HORIZONTAL | Gravity.BOTTOM, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(toastLayout); toast.show(); }
From source file:com.bt.download.android.gui.util.UIUtils.java
public static void showToastMessage(Context context, String message, int duration, int gravity, int xOffset, int yOffset) { if (context != null && message != null) { Toast toast = Toast.makeText(context, message, duration); if (gravity != (Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)) { toast.setGravity(gravity, xOffset, yOffset); }// www .j a v a 2s. co m toast.show(); } }
From source file:com.ppshein.PlanetMyanmarDictionary.common.java
public static void addBookmark(String notedword, Context context) { try {/*from w ww . ja va 2 s.c o m*/ DatabaseUtil dbUtil = new DatabaseUtil(context); dbUtil.open(); Cursor cursor = dbUtil.fetchBookmark(notedword); String getReturn = cursor.getString(1); cursor.close(); dbUtil.close(); Log.v("Existing Bookmarks", getReturn); } catch (Exception e) { DatabaseUtil dbUtil = new DatabaseUtil(context); dbUtil.open(); dbUtil.insertBookmark(notedword); dbUtil.close(); Toast toast = Toast.makeText(context, "Successfully bookmarked", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } }
From source file:com.frostwire.android.gui.util.UIUtils.java
private static void showToastMessage(Context context, String message, int duration, int gravity, int xOffset, int yOffset) { if (context != null && message != null) { Toast toast = Toast.makeText(context, message, duration); if (gravity != (Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)) { toast.setGravity(gravity, xOffset, yOffset); }//ww w . j a v a2 s . c o m toast.show(); } }
From source file:com.commonsdroid.dialoghelper.DialogHelper.java
/** * Show custom toast./* www.j a va2 s . c o m*/ * * @param context the context * @param view the view * @param Duration the duration e.g <code>Toast.LENGTH_SHORT</code> , <code>Toast.LENGTH_LONG</code> * @param gravity the gravity e.g <code>GRAVITY.BOTTOM</code> , <code>GRAVITY.CENTER_VERTICAL</code> , etc * @param xoffset the x offset * @param yoffset the y offset */ public static void showCustomToast(Context context, View view, int Duration, int gravity, int xoffset, int yoffset) { Toast newCustomToast = new Toast(context); newCustomToast.setView(view); newCustomToast.setDuration(Duration); newCustomToast.setGravity(gravity, xoffset, yoffset); newCustomToast.show(); }
From source file:com.commonsdroid.dialoghelper.DialogHelper.java
/** * Show custom toast.//from w w w.j a v a 2 s .com * * @param context the context * @param view the view * @param gravity the gravity e.g <code>GRAVITY.BOTTOM</code> , <code>GRAVITY.CENTER_VERTICAL</code> , etc * @param xoffset the x offset * @param yoffset the y offset */ public static void showCustomToast(Context context, View view, int gravity, int xoffset, int yoffset) { Toast newCustomToast = new Toast(context); newCustomToast.setView(view); newCustomToast.setDuration(Toast.LENGTH_LONG); newCustomToast.setGravity(gravity, xoffset, yoffset); newCustomToast.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); }//from w ww . java2 s. c o 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); }//from www . j a va 2 s. c o m toast.show(); } }