List of usage examples for android.widget Toast getYOffset
public int getYOffset()
From source file:Main.java
public static void showToast(Context c, String str) { Toast toast = Toast.makeText(c, str, Toast.LENGTH_LONG); toast.setGravity(Gravity.CENTER, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show();/*from www. j a va 2 s. c o m*/ }
From source file:Main.java
public static void ShowToast(Context context, String message) { Toast msg = Toast.makeText(context, message, Toast.LENGTH_SHORT); msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2); msg.show();/*from ww w . j a va 2 s . co m*/ }
From source file:Main.java
public static void toast(String message, Context context) { Toast msg = Toast.makeText(context, message, Toast.LENGTH_LONG); msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2); msg.show();// w w w .j a va 2 s .c om }
From source file:org.prx.prp.view.StationInformationView.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.streaminfoview); final int streamID = this.getIntent().getExtras().getInt("STREAM_ID"); mContext = this; IntentFilter f = new IntentFilter(); f.addAction("org.prx.errorInStream"); this.registerReceiver(mIntentReceiver, new IntentFilter(f)); final ImageButton favoriteImageButton = (ImageButton) findViewById(R.id.station_favorite_button); if (StreamManager.isFavorite(streamID)) favoriteImageButton.setImageResource(R.drawable.tab_favorites); else//from w w w . j a va 2s. c o m favoriteImageButton.setImageResource(R.drawable.tab_no_favorite); favoriteImageButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (StreamManager.isFavorite(streamID)) { StreamManager.removeFavorite(streamID); favoriteImageButton.setImageResource(R.drawable.tab_no_favorite); } else { StreamManager.addFavorite(streamID); favoriteImageButton.setImageResource(R.drawable.tab_favorites); } } }); stream = StreamManager.findById(streamID); TextView streamNameView = (TextView) findViewById(R.id.stream_name_1); TextView StreamNameViewSecondary = (TextView) findViewById(R.id.stream_name_2); streamNameView.setText(stream.getDisplayName()); StreamNameViewSecondary.setText(stream.getDisplayName()); TextView streamStateView = (TextView) findViewById(R.id.stream_state); streamStateView.setText(stream.getSource().getStatePrimary()); listView = (ListView) findViewById(R.id.stream_schedule_list_2); Thread t1 = new Thread(new Runnable() { public void run() { doUpdate(); } }); t1.start(); Toast msg = Toast.makeText(mContext, "Getting stream schedule...", Toast.LENGTH_LONG); msg.setGravity(Gravity.CENTER, msg.getXOffset() / 2, msg.getYOffset() / 2); msg.show(); }
From source file:dev.ronlemire.contactclientcloud.MainActivity.java
private boolean isContactLoaded() { boolean loaded = contactLoaded != null; if (loaded == false) { Toast message = Toast.makeText(this, R.string.no_contact_selected, Toast.LENGTH_SHORT); message.setGravity(Gravity.CENTER, message.getXOffset(), message.getYOffset()); message.show();/*from ww w.j a v a2 s . c om*/ } return loaded; }
From source file:com.lucapernini.misapp.Registration.java
public void showToast(String msg) { Log.i(TAG, "Misa Registration, showToast: " + msg); Toast toast = Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT); toast.setGravity(Gravity.CENTER, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show();/* w w w . j a v a2 s. co m*/ }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityJourney.java
/** * sends a message to the driver of a journey *//*from www. j ava2s . co m*/ private void sendMessageToDriver() { final Dialog customDialog = new Dialog(this); customDialog.setContentView(R.layout.custom_dialog_layout); customDialog.setTitle("Message"); final List<String> spinnerArray = new ArrayList<String>(); spinnerArray.add("Everyone"); if (!getApp().getSelectedJourney().getDriver().equals(getApp().getUser())) { spinnerArray.add(getApp().getSelectedJourney().getDriver().getFullName()); } for (int i = 0; i < getApp().getSelectedJourney().getHitchhikers().size(); i++) { if (!getApp().getSelectedJourney().getHitchhikers().get(i).equals(getApp().getUser())) { spinnerArray.add(getApp().getSelectedJourney().getHitchhikers().get(i).getFullName()); } } final Spinner spinner = (Spinner) customDialog.findViewById(R.id.spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(MapActivityJourney.this, android.R.layout.simple_spinner_item, spinnerArray); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); ImageView sendBtn = (ImageView) customDialog.findViewById(R.id.sendBtn); final EditText input = (EditText) customDialog.findViewById(R.id.input); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { User mid = getApp().getUser(); if (spinner.getSelectedItem().toString().equals("Everyone")) { if (input.getText().toString().equals("")) { input.setHint("Please fill in your message"); Toast toast = Toast.makeText(MapActivityJourney.this, "Please fill in your message", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); } else { List<User> userList = new ArrayList<User>(); userList.add(getApp().getSelectedJourney().getDriver()); for (int k = 0; k < getApp().getSelectedJourney().getHitchhikers().size(); k++) { userList.add(getApp().getSelectedJourney().getHitchhikers().get(k)); } userList.remove(getApp().getUser()); for (int k = 0; k < userList.size(); k++) { sendMessage(userList.get(k), input); } Toast toast = Toast.makeText(MapActivityJourney.this, "Message sent", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); customDialog.dismiss(); } } else { for (int j = 0; j < getApp().getSelectedJourney().getHitchhikers().size(); j++) { if (spinner.getSelectedItem().toString() .equals(getApp().getSelectedJourney().getHitchhikers().get(j).getFullName())) { mid = getApp().getSelectedJourney().getHitchhikers().get(j); } } if (spinner.getSelectedItem().toString() .equals(getApp().getSelectedJourney().getDriver().getFullName())) { mid = getApp().getSelectedJourney().getDriver(); } if (input.getText().toString().equals("")) { input.setHint("Please fill in your message"); Toast toast = Toast.makeText(MapActivityJourney.this, "Please fill in your message", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); } else { sendMessage(mid, input); Toast toast = Toast.makeText(MapActivityJourney.this, "Message sent", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); customDialog.dismiss(); } } } }); customDialog.show(); }
From source file:ca.mcgill.hs.serv.LogFileUploaderService.java
/** * Helper method for making toasts./*w w w .java 2 s. c o m*/ * * @param message * The text to toast. * @param duration * The duration of the toast. */ private void makeToast(final String message, final int duration) { final Toast slice = Toast.makeText(getBaseContext(), getResources().getString(R.string.uploader_appname_label) + message, duration); slice.setGravity(slice.getGravity(), slice.getXOffset(), slice.getYOffset() + 100); slice.show(); }
From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java
/** * Starts an activity where the user can change the order of (or delete) the map points. *///from ww w .j a va2s . c om private void changeOrder() { if (getSelectedRoute() == null || getSelectedRoute().getMapPoints() == null || getSelectedRoute().getMapPoints().size() == 0) { Toast toast = Toast.makeText(this, "You must add some points first", Toast.LENGTH_LONG); toast.setGravity(Gravity.BOTTOM, toast.getXOffset() / 2, toast.getYOffset() / 2); toast.show(); return; } Intent dragAndDropIntent = new Intent(this, no.ntnu.idi.socialhitchhiking.map.draganddrop.DragAndDropListActivity.class); getApp().setSelectedMapRoute(selectedRoute); dragAndDropIntent.putExtra("type", "changeOrder"); dragAndDropIntent.putExtra("editMode", inEditMode); dragAndDropIntent.putExtra("routePosition", positionOfRoute); startActivity(dragAndDropIntent); finish(); }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Shows a Toast alert.//w w w .java 2s .c o 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(); }