List of usage examples for android.widget Toast setGravity
public void setGravity(int gravity, int xOffset, int yOffset)
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.j a v a2 s . 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); }
From source file:com.longle1.facedetection.TimedAsyncHttpResponseHandler.java
@Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { Log.i("RTT", String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms"); String msg = "RTT: " + String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms"; Toast mToast = Toast.makeText(mContext, msg, Toast.LENGTH_SHORT); mToast.setGravity(Gravity.TOP, 0, 0); mToast.show();//from ww w.jav a 2 s . c o m }
From source file:com.siso.app.ui.common.BaseFragment.java
protected void showMiddleToast(String msg) { Toast toast = Toast.makeText(getActivity(), msg, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show();/*w w w.j av a 2 s. c o m*/ }
From source file:com.longle1.facedetection.TimedAsyncHttpResponseHandler.java
@Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { Log.e("RTT", String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms"); String msg = "RTT: " + String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms"; Toast mToast = Toast.makeText(mContext, msg, Toast.LENGTH_SHORT); mToast.setGravity(Gravity.TOP, 0, 0); TextView v = (TextView) mToast.getView().findViewById(android.R.id.message); v.setTextColor(Color.RED);/*from www . j a v a 2s . c o m*/ mToast.show(); }
From source file:de.bolz.android.taglocate.ui.TagEditActivity.java
/** * Shows a Toast on top of the view./*ww w . ja va2 s.c om*/ * @param msg the message to display. * @param length the Toast duration */ protected void showToast(String msg, int length) { Toast t = Toast.makeText(this, msg, length); t.setGravity(Gravity.TOP, 0, 0); t.show(); }
From source file:br.ufrn.dimap.pubshare.download.service.DownloaderService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Toast toast = Toast.makeText(this, "Starting download. see action bar to see the progress.", Toast.LENGTH_SHORT);/*from w w w. j av a 2 s . c o m*/ toast.setGravity(Gravity.BOTTOM | Gravity.CENTER, 0, 0); toast.show(); return super.onStartCommand(intent, flags, startId); }
From source file:org.xingjitong.ui.CallButton.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);// ww w. j a v a2 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:info.guardianproject.iocipher.camera.StillCameraActivity.java
private void notifyUserImageWasSavedSuccessfully() { final Toast toast = Toast.makeText(getApplicationContext(), "image saved successfully!", Toast.LENGTH_SHORT);/*from w ww . ja v a 2 s .c om*/ toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); final int DURATION = 500; new CountDownTimer(DURATION, DURATION) { public void onTick(long millisUntilFinished) { toast.show(); } public void onFinish() { toast.cancel(); } }.start(); }
From source file:com.mb.kids_mind.GcmIntentService.java
public void ToastAll(Context context, String msg) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.toast_layout, null); Toast mToast = new Toast(context.getApplicationContext()); mToast.setGravity(Gravity.CENTER_VERTICAL, 0, 2); mToast.setDuration(Toast.LENGTH_SHORT); mToast.setView(layout);// ww w.j a v a2s . c o m if (flag == false) { flag = true; mToast.show(); new Handler().postDelayed(new Runnable() { @Override public void run() { flag = false; } }, 2000);// ? ?? 2 . } else { Log.e("", " ?"); } }
From source file:com.example.multi_ndef.frag_sms.java
private void displayMessage(String message) { Toast toast = Toast.makeText(getActivity().getApplicationContext(), message, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER | Gravity.CENTER, 0, 0); toast.show();/*from www. ja va 2 s . co m*/ }