List of usage examples for android.widget Toast setView
public void setView(View view)
From source file:com.secbro.qark.tapjacking.TapJackingExploitFragment.java
private Toast createToast() { LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Toast toast = Toast.makeText(this.getActivity(), "", Toast.LENGTH_SHORT); View view = inflater.inflate(R.layout.tap_jacking_toast, null); toast.setView(view); toast.setGravity(Gravity.FILL, 0, 0); return toast; }
From source file:com.woodblockwithoutco.quickcontroldock.ui.ControlService.java
public void attachTemporaryView(Drawable icon, String appName) { LinearLayout l = new LinearLayout(getApplicationContext()); l.setGravity(Gravity.CENTER_VERTICAL); l.setOrientation(LinearLayout.HORIZONTAL); l.setPadding(NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX, NOTIFICATION_TOAST_PADDING_PX); l.setBackgroundResource(R.drawable.notification_toast_bg); TextView tv = new TextView(getApplicationContext()); tv.setGravity(Gravity.CENTER);/*w w w . j ava 2 s . c o m*/ tv.setCompoundDrawablePadding(COMPOUND_DRAWABLE_PADDING_PX); tv.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); String notificationText = getString(R.string.notification_from) + "\n" + appName; tv.setText(notificationText); tv.setTextColor(COLOR_WHITE); l.addView(tv); Toast toast = new Toast(getApplicationContext()); toast.setView(l); toast.show(); }
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); if (flag == false) { flag = true;// w w w.ja v a2 s . c om mToast.show(); new Handler().postDelayed(new Runnable() { @Override public void run() { flag = false; } }, 2000);// ? ?? 2 . } else { Log.e("", " ?"); } }
From source file:org.apps8os.motivator.ui.CheckEventsActivity.java
/** * Displaying toast after checking events *///from w ww . ja v a 2 s.c o m private void eventsChecked() { View toastLayout = (View) getLayoutInflater().inflate(R.layout.element_mood_toast, (ViewGroup) findViewById(R.id.mood_toast_layout)); TextView toastText = (TextView) toastLayout.findViewById(R.id.mood_toast_text); toastText.setText(getString(R.string.plan_checked)); toastText.setTextColor(Color.WHITE); Toast planChecked = new Toast(getApplicationContext()); planChecked.setDuration(Toast.LENGTH_SHORT); planChecked.setView(toastLayout); planChecked.show(); finish(); }
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);/*w ww . java 2 s. c om*/ Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.TOP, 0, -1); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); toast.show(); }
From source file:in.cubestack.material.androidmaterial.ui.AbstractCubeStackActivity.java
public void toast(String message, int duration) { Toast toast = Toast.makeText(this, message, duration); TextView toastView = (TextView) LayoutInflater.from(this).inflate(R.layout.toast, null); toastView.setText(message);// w ww . j ava2 s . c om toast.setView(toastView); toast.show(); }
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);/* w w w.j a va 2 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:com.scoreloop.android.coreui.BaseActivity.java
void showToast(final String message) { final View view = getLayoutInflater().inflate(R.layout.sl_dialog_custom, null); ((TextView) view.findViewById(R.id.message)).setText(message); final Toast toast = new Toast(getApplicationContext()); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(view); toast.show();/* w ww. j a va 2 s. co m*/ }
From source file:de.tudarmstadt.informatik.secuso.phishedu2.MainActivity.java
@Override public void displayToastScore(int score) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.fragment_toast_score, (ViewGroup) findViewById(R.id.toast_layout_root)); String scoreString = Integer.toString(score); TextView text = (TextView) layout.findViewById(R.id.text); if (score < 0) { // red//from w ww. j a v a 2 s. co m text.setTextColor(Color.rgb(135, 0, 0)); } else { // green text.setTextColor(Color.rgb(0, 135, 0)); scoreString = "+ " + score; } text.setText(getString(R.string.scoreString, scoreString)); // scoreString + " Punkte" text.setTypeface(Typeface.DEFAULT_BOLD); Toast toast = new Toast(getApplicationContext()); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); toast.show(); }
From source file:org.apps8os.motivator.ui.MoodQuestionActivity.java
/** Called when the activity is first created. */ @Override// ww w . j av a 2 s .c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mood_question); mDayDataHandler = new DayDataHandler(this); mCardsViewPagerEnergy = (ViewPager) findViewById(R.id.mood_question_viewpager_cards); mCardsViewPagerEnergy.setAdapter(new ImagesPagerAdapter(mImages1, mTitles1, this)); setViewPager(mCardsViewPagerEnergy); mEnergyLevelText = (TextView) findViewById(R.id.mood_question_energylevel_textview); mEnergyLevelText.setText(mCardsViewPagerEnergy.getAdapter().getPageTitle(DEFAULT_MOOD_SELECTION)); // Set an OnPageChangeListener to the ViewPager, change the text when a page is selected mCardsViewPagerEnergy .setOnPageChangeListener(new ViewPageChangeListener(mCardsViewPagerEnergy, mEnergyLevelText)); mCardsViewPagerMood = (ViewPager) findViewById(R.id.mood_question_viewpager_cards2); mCardsViewPagerMood.setAdapter(new ImagesPagerAdapter(mImages2, mTitles2, this)); setViewPager(mCardsViewPagerMood); // Get the text field for energy level mMoodLevelText = (TextView) findViewById(R.id.mood_question_moodlevel_textview); mMoodLevelText.setText(mCardsViewPagerMood.getAdapter().getPageTitle(DEFAULT_MOOD_SELECTION)); // Set an OnPageChangeListener to the ViewPager, change the text when a page is selected mCardsViewPagerMood .setOnPageChangeListener(new ViewPageChangeListener(mCardsViewPagerMood, mMoodLevelText)); final LayoutInflater inflater = getLayoutInflater(); LinearLayout buttons = (LinearLayout) findViewById(R.id.mood_question_buttons); // Change the OK button to next button which opens the checking events activity if there are events to check. final Bundle extras = getIntent().getExtras(); if (extras != null && extras.getBoolean(EventDataHandler.EVENTS_TO_CHECK, false)) { Button nextButton = (Button) inflater.inflate(R.layout.element_ok_button, buttons, false); nextButton.setText(getString(R.string.next)); nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { saveMood(v); Intent intent = new Intent(MoodQuestionActivity.this, CheckEventsActivity.class); intent.putExtra(MotivatorEvent.YESTERDAYS_EVENTS, extras.getParcelableArrayList(MotivatorEvent.YESTERDAYS_EVENTS)); startActivity(intent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(NotificationService.NOTIFICATION_ID_MOOD); finish(); } }); buttons.addView(nextButton); } else { Button okButton = (Button) inflater.inflate(R.layout.element_ok_button, buttons, false); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { saveMood(v); String toastMsg; if (mCardsViewPagerMood.getCurrentItem() > 2) { toastMsg = getString(R.string.questionnaire_done_toast_good_mood); } else if (mCardsViewPagerMood.getCurrentItem() == 2) { toastMsg = getString(R.string.questionnaire_done_toast_ok_mood); } else { toastMsg = getString(R.string.questionnaire_done_toast_bad_mood); } View toastLayout = (View) inflater.inflate(R.layout.element_mood_toast, (ViewGroup) findViewById(R.id.mood_toast_layout)); TextView toastText = (TextView) toastLayout.findViewById(R.id.mood_toast_text); toastText.setText(toastMsg); toastText.setTextColor(Color.WHITE); Toast questionnaireDone = new Toast(getApplicationContext()); questionnaireDone.setDuration(Toast.LENGTH_SHORT); questionnaireDone.setView(toastLayout); questionnaireDone.show(); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(NotificationService.NOTIFICATION_ID_MOOD); finish(); } }); buttons.addView(okButton); } }