Custom Toast
//
*********** Creating Custom Toast ***********
public void
CustomToast(String msg) {
ViewGroup parent =
(ViewGroup) findViewById(R.id.container);
LayoutInflater inflater
= getLayoutInflater();
View customToastroot =
inflater.inflate(R.layout.toast,
parent , false);
Toast customtoast = new
Toast(BookNow.this);
TextView tv_tost =
(TextView)customToastroot.findViewById(R.id.tv_tost);
tv_tost.setText(msg);
customtoast.setView(customToastroot);
customtoast.setGravity(Gravity.CENTER_HORIZONTAL |
Gravity.CENTER_VERTICAL, 0, 0);
customtoast.setDuration(Toast.LENGTH_LONG);
customtoast.show();
}
you just have to call the method CustomToast() where ever you need .
No comments:
Post a Comment