List of usage examples for android.widget Toast setGravity
public void setGravity(int gravity, int xOffset, int yOffset)
From source file:com.github.andrewlord1990.snackbarbuilder.toastbuilder.ToastBuilder.java
private void setToastGravity(Toast toast) { if (gravity != 0) { toast.setGravity(gravity, gravityOffsetX, gravityOffsetY); } }
From source file:com.kobi.metalsexchange.app.CalculateFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.menu_copy) { // Gets a handle to the clipboard service. ClipboardManager clipboard = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); String price = Utility.getFormattedCurrency(calculateFragmentViewHelper.getPriceResult(), Utility.getPreferredCurrency(getActivity()), getActivity(), false); ClipData clip = ClipData.newPlainText("rate", price); clipboard.setPrimaryClip(clip);/*from ww w .jav a2 s. co m*/ Toast toast = Toast.makeText(getActivity().getBaseContext(), getString(R.string.copy_to_clipboard_toast, price), Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } return super.onOptionsItemSelected(item); }
From source file:com.example.clienttest.AbstractGreenhouseActivity.java
protected void displayNetworkError() { Toast toast = Toast.makeText(this, "A problem occurred with the network connection while attempting to communicate with Greenhouse.", Toast.LENGTH_LONG);// w w w. j a v a 2s .c om toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); }
From source file:com.android.jhansi.designchallenge.NavigationDrawerActivity.java
private void showCustomToast(int resId) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.custom_toast_layout)); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(resId);//from www. j av a 2 s . c o m Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.TOP, 0, -1); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); 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);/*from w w w . ja v a2s .c o m*/ toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.show(); }
From source file:es.glasspixel.wlanaudit.activities.KeyListActivity.java
/** * Handles the event of clicking on a list element. *//*from w w w. j a v a 2s.c om*/ protected void onListItemClick(ListView l, View v, int position, long id) { // Clipboard copy ClipboardManager clipBoard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipBoard.setText(mKeyList.get(position)); // Copy notification Toast notificationToast = Toast.makeText(this, getResources().getString(R.string.key_copy_success), Toast.LENGTH_SHORT); notificationToast.setGravity(Gravity.CENTER, 0, 0); notificationToast.show(); }
From source file:autobahn.demo.com.autobahndemo.EchoClientActivity.java
private void alert(String message) { Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show();/*from w ww . j a va 2s. co m*/ }
From source file:app.dropbox.encryption.encryptionsetup.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.encryption_setup); initilizingVariables();/*from w w w .j a va 2 s. c o m*/ if (encryptKey != null) { if (fileToEncrypt != null) launchEncryption(); else launchnext(); } else { // acctok=getSharedPreferences("accesstoken",0); // accessToken =acctok.getString("accesstoken", null); // if(accessToken==null){ // goback(); // } // final EditText key = (EditText) findViewById(R.id.editText1); ImageButton encrypt = (ImageButton) findViewById(R.id.imageButton1); encrypt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { encryptKey = key.getText().toString(); if (keyValidator(encryptKey)) { key.setText(""); setKeyToPreferences(); if (fileToEncrypt != null) launchEncryption(); else launchnext(); } else { Toast toast = Toast.makeText(encryptionsetup.this, "Enter key between 5 to 16 Characters", 2000); toast.setGravity(Gravity.CENTER, 0, 0); toast.show(); } } }); } }
From source file:cm.aptoide.pt.webservices.login.CreateUser.java
public void signUp(View v) { username = username_box.getText().toString(); password = password_box.getText().toString(); if (username.trim().length() > 0 && password.trim().length() > 0) { new CreateUserTask().execute(username.trim(), password.trim()); } else {/*w w w . ja v a 2 s . co m*/ Toast toast = Toast.makeText(context, context.getString(R.string.check_your_credentials), Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 30); toast.show(); } }
From source file:zuo.biao.library.ui.SelectPictureActivity.java
/**?uri?? * @param selectedImage/* ww w. ja va2s. c om*/ */ private void sendPicByUri(Uri selectedImage) { Cursor cursor = getContentResolver().query(selectedImage, null, null, null, null); if (cursor != null) { cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex("_data"); 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; } } 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; } picturePath = file.getAbsolutePath(); } setResult(RESULT_OK, new Intent().putExtra(RESULT_PICTURE_PATH, picturePath)); }