List of usage examples for android.widget Toast setView
public void setView(View view)
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.andrewshu.android.reddit.common.Common.java
public static void showErrorToast(String error, int duration, Context context) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); Toast t = new Toast(context); t.setDuration(duration);//from w w w . j a v a 2 s .c o m View v = inflater.inflate(R.layout.error_toast, null); TextView errorMessage = (TextView) v.findViewById(R.id.errorMessage); errorMessage.setText(error); t.setView(v); t.show(); }
From source file:csic.ceab.movelab.beepath.Util.java
/** * Displays a brief message on the phone screen. Taken from Human Mobility * Project code written by Chang Y. Chung and Necati E. Ozgencil. * //from w w w . jav a2 s. c o m * @param context * Interface to application environment * @param msg * The message to be displayed to the user */ public static void toast(Context context, String msg) { TextView tv = new TextView(context); tv.setText(msg); Drawable bknd = context.getResources().getDrawable(R.drawable.white_border); tv.setBackgroundDrawable(bknd); tv.setPadding(20, 20, 20, 20); tv.setTextSize(20); Toast t = new Toast(context); t.setDuration(Toast.LENGTH_LONG); t.setView(tv); t.show(); }
From source file:com.bbxiaoqu.api.util.Utils.java
public static void makeEventToast(Context context, String text, boolean isLongToast) { Toast toast = null; if (isLongToast) { toast = Toast.makeText(context, "", Toast.LENGTH_LONG); } else {/*from ww w.ja v a 2 s .c o m*/ toast = Toast.makeText(context, "", Toast.LENGTH_SHORT); } View v = LayoutInflater.from(context).inflate(R.layout.toast_view, null); TextView textView = (TextView) v.findViewById(R.id.text); textView.setText(text); toast.setView(v); toast.show(); }
From source file:MainActivity.java
public void showToast(View view) { LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.toast_custom, null); ((TextView) layout.findViewById(android.R.id.message)).setText("Custom Toast"); Toast toast = new Toast(this); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show();/*from www . j av a2s . com*/ }
From source file:com.endiansoftware.echo.remotewatch.GcmBroadcastReceiver.java
@Override public void onReceive(Context context, Intent intent) { /*//from w w w .j av a2s .co m // Explicitly specify that GcmIntentService will handle the intent. ComponentName comp = new ComponentName(context.getPackageName(), GcmIntentService.class.getName()); // Start the service, keeping the device awake while it is launching. startWakefulService(context, (intent.setComponent(comp))); setResultCode(Activity.RESULT_OK); */ /* // ? ?? . Intent popupIntent = new Intent(context, Popup.class) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // . context.startActivity(popupIntent); */ LinearLayout layout = new LinearLayout(context); //layout.setBackgroundResource(R.color.LightOrange); TextView tv = new TextView(context); // set the TextView properties like color, size etc tv.setTextColor(Color.RED); tv.setTextSize(15); tv.setGravity(Gravity.CENTER_VERTICAL); // set the text you want to show in Toast tv.setText("My Custom Toast at Bottom of Screen"); layout.addView(tv); Toast toast = new Toast(context); //context is object of Context write "this" if you are an Activity // Set The layout as Toast View toast.setView(layout); // Position you toast here toast position is 50 dp from bottom you can give any integral value toast.setGravity(Gravity.BOTTOM, 0, 50); toast.show(); }
From source file:codepath.watsiapp.activities.BaseFragmentActivity.java
private void showThankYouNote() { LayoutInflater inflater = this.getLayoutInflater(); View view = inflater.inflate(R.layout.toast_thanks_for_donation, (ViewGroup) this.findViewById(R.id.thanks_note)); Toast toast = new Toast(this); toast.setView(view); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.show();// w w w . ja va2s .c o m }
From source file:com.github.andrewlord1990.snackbarbuilder.toastbuilder.ToastBuilder.java
private TextView setupToastView(Toast toast) { if (customView != null) { toast.setView(customView); TextView messageView = setCustomViewMessage(); if (messageView != null) { return messageView; }//from w w w . j a va 2 s . c om } return getToastMessageView(toast.getView()); }
From source file:com.radicaldynamic.groupinform.application.Collect.java
public void showCustomToast(String message) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.toast_view, null); // Set the text in the view TextView tv = (TextView) view.findViewById(R.id.message); tv.setText(message);//from w w w .ja v a2s.co m Toast t = new Toast(this); t.setView(view); t.setDuration(Toast.LENGTH_SHORT); t.setGravity(Gravity.CENTER, 0, 0); t.show(); }
From source file:com.accia77.mockey.ui.PapiroActivity.java
@Override public void onResume() { super.onResume(); setTitle(MyApplication.getInstance().getMainActivityTitle()); massimaSceltaTextView = (TextView) findViewById(R.id.massimaSceltaTextView); String stringaTextView = currentEntry.getUserEditedEntry(); if (mDoShowAndPlayQuote) { // Custom toast con il testo della frase LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.papiro_toast, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView image = (ImageView) layout.findViewById(R.id.papiro_toast_image); image.setImageResource(R.drawable.ic_small_monkey_head); TextView text = (TextView) layout.findViewById(R.id.papiro_toast_text); text.setText(stringaTextView);//from w w w . ja v a2s.c om Toast toast = new Toast(this); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); toast.show(); // Playback of the quote if (currentEntry.getEntryType() == MySQLiteHelper.ENTRY_TYPE_PURE_TEXT) { MyApplication.getInstance().playSelection(currentEntry); } else if (currentEntry.getEntryType() == MySQLiteHelper.ENTRY_TYPE_AUDIO) { // No playback if the sd card is not mounted if (MyApplication.getInstance().isSdCardMounted(false)) { MyApplication.getInstance().playSelection(currentEntry); } } mDoShowAndPlayQuote = false; } if (MyApplication.getInstance().isDefaultPapiroLoaded()) { massimaSceltaTextView.setText(stringaTextView); massimaSceltaTextView.setVisibility(View.VISIBLE); } else massimaSceltaTextView.setVisibility(View.INVISIBLE); }