List of usage examples for android.widget Toast setView
public void setView(View view)
From source file:com.sim2dial.dialer.InCallActivity.java
public void displayCustomToast(final String message, final int duration) { mHandler.post(new Runnable() { @Override//from w ww .j ava 2 s . c om public void run() { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot)); TextView toastText = (TextView) layout.findViewById(R.id.toastMessage); toastText.setText(message); final Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(duration); toast.setView(layout); toast.show(); } }); }
From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java
/** * Starts the whole Facebook post process. * //from w w w .ja va 2s. c om * @param session */ private void launchPostProcess(final Session session) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(R.drawable.icon_facebook_released); TextView text = (TextView) layout.findViewById(R.id.text); text.setText("Publication en cours"); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); Request request = Request.newMeRequest(session, new Request.GraphUserCallback() { @Override public void onCompleted(GraphUser user, Response response) { if (session == Session.getActiveSession()) { if (user != null) { int notificationId = FacebookHelper .showNotificationStartProgress(GameSetHistoryActivity.this); AppContext.getApplication().getNotificationIds().put(tempGameSet.getUuid(), notificationId); AppContext.getApplication().setLoggedFacebookUser(user); UpSyncGameSetTask task = new UpSyncGameSetTask(GameSetHistoryActivity.this, progressDialog); task.setCallback(GameSetHistoryActivity.this.upSyncCallback); task.execute(tempGameSet); currentRunningTask = task; } } if (response.getError() != null) { // //progressDialog.dismiss(); // Session newSession = new // Session(GameSetHistoryActivity.this); // Session.setActiveSession(newSession); // newSession.openForPublish(new // Session.OpenRequest(GameSetHistoryActivity.this).setPermissions(Arrays.asList("publish_actions", // "email")).setCallback(facebookSessionStatusCallback)); } } }); request.executeAsync(); }
From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java
private Toast createToastShort(String text) { Toast toast = new Toast(this); TextView tv = new TextView(this); tv.setText(text);// ww w . ja v a 2s . c om tv.setTextColor(ContextCompat.getColor(this, R.color.colorAccent)); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, TOAST_TEXT_SIZE); // int pixel = (int)mWindowDensity * 56; int toastMargin = getResources().getDimensionPixelSize(R.dimen.toast_margin_top_bottom); tv.setPadding(0, toastMargin, 0, toastMargin); toast.setView(tv); toast.setGravity(mToastPosition, 0, 0); toast.setDuration(Toast.LENGTH_SHORT); return toast; }
From source file:org.xingjitong.InCallActivity.java
private void toastdsp(String str) { LayoutInflater inflater = getLayoutInflater(); //LayoutInflater inflater = LayoutInflater.from(getContext()); View layout = inflater.inflate(R.layout.customtoast, (ViewGroup) findViewById(R.id.llcustomtoast)); //ImageView image = (ImageView) layout.findViewById(R.id.customtoast_img); //image.setImageResource(R.drawable.status_green); //yypp TextView text = (TextView) layout.findViewById(R.id.customtoast_text); text.setText(str);/*from w w w .ja v a 2 s . c o m*/ Toast toast = new Toast(getApplicationContext()); //Toast toast = new Toast(getContext()); toast.setGravity(Gravity.CENTER, 0, 60); //toast.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); }
From source file:co.taqat.call.CallActivity.java
public void displayCustomToast(final String message, final int duration) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot)); TextView toastText = (TextView) layout.findViewById(R.id.toastMessage); toastText.setText(message);//ww w .j a v a 2 s . co m final Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(duration); toast.setView(layout); toast.show(); }
From source file:org.xingjitong.LinphoneActivity.java
public void displayCustomToast(final String message, final int duration) { mHandler.post(new Runnable() { @Override//from ww w . j a v a 2 s . c o m public void run() { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toastRoot)); TextView toastText = (TextView) layout.findViewById(R.id.toastMessage); toastText.setText(message); final Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(duration); toast.setView(layout); toast.show(); } }); }
From source file:com.ezac.gliderlogs.FlightOverviewActivity.java
private void makeToast(String msg, int mode) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root)); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(R.drawable.ic_launcher); TextView text = (TextView) layout.findViewById(R.id.text); text.setText(msg);//from w ww. j av a 2 s .c o m Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); if (mode == 1) { text.setTextColor(Color.WHITE); toast.getView().setBackgroundColor(Color.RED); toast.setDuration(Toast.LENGTH_LONG); } if (mode == 2) { text.setTextColor(Color.WHITE); toast.getView().setBackgroundColor(Color.GREEN); } toast.show(); }
From source file:com.bookkos.bircle.CaptureActivity.java
private void customToast(String toast_text, int icon, boolean bool) { getLayoutInflater();/*ww w . ja va 2 s.c om*/ LayoutInflater inflater = getLayoutInflater(); int resource = 0; if (bool == true) { resource = R.layout.success_toast; } else { resource = R.layout.failure_toast; } View layout = inflater.inflate(resource, null); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(icon); TextView text = (TextView) layout.findViewById(R.id.text); text.setText(Html.fromHtml(toast_text)); final Toast toast = new Toast(this); layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toast.cancel(); } }); toast.setView(layout); toast.setGravity(Gravity.CENTER, 0, 0); if (modeFlag == true) { toast.setDuration(Toast.LENGTH_SHORT); } else { toast.setDuration(Toast.LENGTH_LONG); } toast.show(); // Toast.makeText(context, toast_text, Toast.LENGTH_SHORT).show(); }
From source file:org.smilec.smile.student.CourseList.java
public void showToast(String msg) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root)); TextView text = (TextView) layout.findViewById(R.id.text); text.setText(msg);//from w ww . j a v a 2 s . com Toast toast = new Toast(getApplicationContext()); if (smile.face != null) text.setTypeface(smile.face); text.setText(msg); toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 100); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); }
From source file:com.kll.collect.android.activities.FormEntryActivity.java
/** * Creates a toast with the specified message. * * @param message//from w w w.j av a2s . com */ private void showCustomToast(String message, int duration) { 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); Toast t = new Toast(this); t.setView(view); t.setDuration(duration); t.setGravity(Gravity.CENTER, 0, 0); t.show(); }