List of usage examples for android.widget Toast Toast
public Toast(Context context)
From source file:org.madmatrix.zxing.android.CaptureActivity.java
public void showMyToast(String content) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout)); TextView toast_content = (TextView) layout.findViewById(R.id.toast_content); toast_content.setText(content);// ww w .java 2s .c o m Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); toast.show(); }
From source file:com.sim2dial.dialer.InCallActivity.java
public void displayCustomToast(final String message, final int duration) { mHandler.post(new Runnable() { @Override//from w w w . j ava2s.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.commonsdroid.dialoghelper.DialogHelper.java
/** * Show custom toast.// ww w . ja v a2s . c o m * * @param context the context * @param view the view */ public static void showCustomToast(Context context, View view) { Toast newCustomToast = new Toast(context); newCustomToast.setView(view); newCustomToast.setDuration(Toast.LENGTH_LONG); newCustomToast.show(); }
From source file:com.commonsdroid.dialoghelper.DialogHelper.java
/** * Show custom toast.//from www . jav a 2 s . com * * @param context the context * @param view the view * @param Duration the duration e.g <code>Toast.LENGTH_SHORT</code> , <code>Toast.LENGTH_LONG</code> */ public static void showCustomToast(Context context, View view, int Duration) { Toast newCustomToast = new Toast(context); newCustomToast.setView(view); newCustomToast.setDuration(Duration); newCustomToast.show(); }
From source file:com.crearo.gpslogger.ui.fragments.display.GpsSimpleViewFragment.java
@Override public void onClick(View view) { Toast toast = new Toast(getActivity()); switch (view.getId()) { case R.id.simpleview_imgSatelliteCount: toast = getToast(R.string.txt_satellites); break;/* ww w . j av a2 s . c o m*/ case R.id.simpleview_imgAccuracy: toast = getToast(R.string.txt_accuracy); break; case R.id.simpleview_imgAltitude: toast = getToast(R.string.txt_altitude); break; case R.id.simpleview_imgDirection: toast = getToast(R.string.txt_direction); break; case R.id.simpleview_imgDuration: toast = getToast(R.string.txt_travel_duration); break; case R.id.simpleview_imgSpeed: toast = getToast(R.string.txt_speed); break; case R.id.simpleview_distance: toast = getToast(R.string.txt_travel_distance); break; case R.id.simpleview_points: toast = getToast(R.string.txt_number_of_points); break; case R.id.simpleview_imgLink: toast = getToast(preferenceHelper.getCustomLoggingUrl()); break; } int location[] = new int[2]; view.getLocationOnScreen(location); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0], location[1]); toast.show(); }
From source file:com.commonsdroid.dialoghelper.DialogHelper.java
/** * Show custom toast.//from w w w .j a v a 2s . c o m * * @param context the context * @param view the view * @param gravity the gravity e.g <code>GRAVITY.BOTTOM</code> , <code>GRAVITY.CENTER_VERTICAL</code> , etc * @param xoffset the x offset * @param yoffset the y offset */ public static void showCustomToast(Context context, View view, int gravity, int xoffset, int yoffset) { Toast newCustomToast = new Toast(context); newCustomToast.setView(view); newCustomToast.setDuration(Toast.LENGTH_LONG); newCustomToast.setGravity(gravity, xoffset, yoffset); newCustomToast.show(); }
From source file:com.sean.takeastand.alarmprocess.AlarmService.java
private void showPraise() { String praise = praiseForUser(); if (mainActivityVisible) { Intent intent = new Intent(Constants.PRAISE_FOR_USER); intent.putExtra("Praise", praise); LocalBroadcastManager.getInstance(this).sendBroadcastSync(intent); } else {// w w w .java 2s . com if (Utils.getToastEnabled(this)) { LayoutInflater inflater = (LayoutInflater) getApplication() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.custom_toast, null); TextView text = (TextView) layout.findViewById(R.id.toast_text); text.setText(praise); Toast toast = new Toast(getApplicationContext()); //toast.setGravity(Gravity.CENTER, 0, 0); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); } } }
From source file:org.nla.tarotdroid.lib.ui.GameSetHistoryActivity.java
/** * Starts the whole Facebook post process. * //from ww w . j a v a2s . c o m * @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:com.commonsdroid.dialoghelper.DialogHelper.java
/** * Show custom toast.// w w w . j ava 2s . co m * * @param context the context * @param view the view * @param Duration the duration e.g <code>Toast.LENGTH_SHORT</code> , <code>Toast.LENGTH_LONG</code> * @param gravity the gravity e.g <code>GRAVITY.BOTTOM</code> , <code>GRAVITY.CENTER_VERTICAL</code> , etc * @param xoffset the x offset * @param yoffset the y offset */ public static void showCustomToast(Context context, View view, int Duration, int gravity, int xoffset, int yoffset) { Toast newCustomToast = new Toast(context); newCustomToast.setView(view); newCustomToast.setDuration(Duration); newCustomToast.setGravity(gravity, xoffset, yoffset); newCustomToast.show(); }
From source file:org.osm.keypadmapper2.KeypadMapper2Activity.java
@Override public void onResume() { super.onResume(); instance = this; Log.d(TAG, "resume"); ControllableResourceInitializerService.startResourceLoading(getApplicationContext(), "lang_support_codes", "lang_support_names", "lang_support_urls"); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mapper.addNotificationListener(this); if (KeypadMapperApplication.getInstance().getSettings().isCompassAvailable()) { sensorManager.registerListener(this, gsensor, SensorManager.SENSOR_DELAY_UI); sensorManager.registerListener(this, msensor, SensorManager.SENSOR_DELAY_UI); }//from w w w .j a va 2s. c om locationProvider.addLocationListener(this); mapper.onResume(); menu.onResume(); satelliteInfo.onResume(); String languageToLoad = KeypadMapperApplication.getInstance().getSettings().getCurrentLanguageCode(); if (!lang.equals(languageToLoad) || uiOptimizationEnabled != KeypadMapperApplication.getInstance() .getSettings().isLayoutOptimizationEnabled()) { Intent localIntent = new Intent(this, KeypadMapper2Activity.class); Bundle data = new Bundle(); data.putInt("state", state.ordinal()); data.putBoolean("extended_address", extendedAddressActive); data.putBoolean("sat_info", satteliteInfoVisible); localIntent.putExtras(data); startActivity(localIntent); finish(); } else { updateLocale(); } if (!locationProvider.isLocationServiceEnabled()) { showDialogGpsDisabled(); } else if (gpsDialog != null) { gpsDialog.dismiss(); gpsDialog = null; } if (KeypadMapperApplication.getInstance().getSettings().isLayoutOptimizationEnabled()) { // show empty toast so that there's no problem with showing // optimized view. On some phones with Android 2.3 and maybe others, // layout isn't rendered in fullscreen and showing toast fixes it. View etv = getLayoutInflater().inflate(R.layout.empty_toast_view, null); Toast t = new Toast(getApplicationContext()); t.setView(etv); t.setDuration(1); t.show(); } RateMeActivity.startRateMe(this); }