List of usage examples for android.widget Toast setGravity
public void setGravity(int gravity, int xOffset, int yOffset)
From source file:jackpal.androidterm.Term.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.menu_preferences: doPreferences();//from w ww . j a v a 2 s . c o m break; case R.id.menu_paste: doPaste(); break; case R.id.menu_new_window: doCreateNewWindow(); break; case R.id.menu_plus: { EmulatorView view = getCurrentEmulatorView(); if (view != null) { int key = mSettings.getActionBarPlusKeyAction(); return doSendActionBarKey(view, key); } break; } // case R.id.menu_minus: { // EmulatorView view = getCurrentEmulatorView(); // if (view != null) { // int key = mSettings.getActionBarMinusKeyAction(); // return doSendActionBarKey(view, key); // } // break; // } case R.id.menu_close_window: confirmCloseWindow(); break; case R.id.menu_x: { EmulatorView view = getCurrentEmulatorView(); if (view != null) { int key = mSettings.getActionBarXKeyAction(); return doSendActionBarKey(view, key); } break; } // case R.id.menu_user: { // EmulatorView view = getCurrentEmulatorView(); // if (view != null) { // int key = mSettings.getActionBarUserKeyAction(); // return doSendActionBarKey(view, key); // } // break; // } case R.id.menu_window_list: startActivityForResult(new Intent(this, WindowList.class), REQUEST_CHOOSE_WINDOW); break; case R.id.menu_reset: doResetTerminal(); Toast toast = Toast.makeText(this, R.string.reset_toast_notification, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); break; case R.id.menu_send_email: doEmailTranscript(); break; case R.id.menu_special_keys: doDocumentKeys(); break; case R.id.menu_toggle_soft_keyboard: doToggleSoftKeyboard(); break; case R.id.menu_toggle_function_bar: setFunctionBar(2); break; case R.id.menu_toggle_wakelock: doToggleWakeLock(); break; case R.id.menu_toggle_wifilock: doToggleWifiLock(); break; case R.id.action_help: Intent openHelp = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.help_url))); startActivity(openHelp); break; case R.id.menu_scripts: startActivity(new Intent(this, CommandListActivity.class)); break; } // Hide the action bar if appropriate if (mActionBarMode >= TermSettings.ACTION_BAR_MODE_HIDES) { mActionBar.hide(); } return super.onOptionsItemSelected(item); }
From source file:org.xingjitong.LinphoneActivity.java
public void displayCustomToast(final String message, final int duration) { mHandler.post(new Runnable() { @Override//from w w w. j a v a2s . com 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:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Shows a Toast alert./*from w w w. ja v a 2s . co m*/ * * @param context * @param message * @param centerOnScreen Set to TRUE to center on the screen. */ public static void dialog_showToastAlert(Context context, String message, boolean centerOnScreen) { Toast msg = Toast.makeText(context, message, Toast.LENGTH_SHORT); if (centerOnScreen) { msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2); } msg.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);//ww w. j ava2s. c om 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: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);// w w w. j a v a 2 s . c o m 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.bookkos.bircle.CaptureActivity.java
private void customToast(String toast_text, int icon, boolean bool) { getLayoutInflater();/*from w w w. j ava2s .c o m*/ 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:xj.property.activity.HXBaseActivity.ChatActivity.java
/** * ?uri??//from w ww. j a va 2 s . co m * * @param selectedImage */ private void sendPicByUri(Uri selectedImage) { // String[] filePathColumn = { MediaStore.Images.Media.DATA }; Cursor cursor = getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); String picturePath = cursor.getString(columnIndex); cursor.close(); cursor = null; if (picturePath == null || picturePath.equals("null")) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } if (TextUtils.equals(servantType, Config.SERVANT_TYPE_BANGBANG) || TextUtils.equals(servantType, Config.SERVANT_TYPE_WEIXIUTOUSU) || TextUtils.equals(servantType, Config.SERVANT_TYPE_SHOPTOUSU) || TextUtils.equals(servantType, Config.SERVANT_TYPE_WUYE)) { sendPictureServantOrComplain(picturePath); } else { sendPicture(picturePath); } } else { File file = new File(selectedImage.getPath()); if (!file.exists()) { Toast toast = Toast.makeText(this, "?", Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); return; } if (TextUtils.equals(servantType, Config.SERVANT_TYPE_BANGBANG) || TextUtils.equals(servantType, Config.SERVANT_TYPE_WEIXIUTOUSU) || TextUtils.equals(servantType, Config.SERVANT_TYPE_SHOPTOUSU) || TextUtils.equals(servantType, Config.SERVANT_TYPE_WUYE)) { sendPictureServantOrComplain(file.getAbsolutePath()); } else { sendPicture(file.getAbsolutePath()); } } }
From source file:com.kll.collect.android.activities.FormEntryActivity.java
/** * Creates a toast with the specified message. * * @param message//from w ww . j av a 2s . co m */ 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(); }
From source file:de.vanita5.twittnuker.util.Utils.java
public static void showMenuItemToast(final View v, final CharSequence text, final boolean isBottomBar) { final int[] screenPos = new int[2]; final Rect displayFrame = new Rect(); v.getLocationOnScreen(screenPos);/*from w w w.j a v a 2 s . c o m*/ v.getWindowVisibleDisplayFrame(displayFrame); final int width = v.getWidth(); final int height = v.getHeight(); final int screenWidth = v.getResources().getDisplayMetrics().widthPixels; final Toast cheatSheet = Toast.makeText(v.getContext(), text, Toast.LENGTH_SHORT); if (isBottomBar) { // Show along the bottom center cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); } else { // Show along the top; follow action buttons cheatSheet.setGravity(Gravity.TOP | Gravity.RIGHT, screenWidth - screenPos[0] - width / 2, height); } cheatSheet.show(); }