I just need to override the show()
method for the Toast
class. I created a class which extends Toast
class, but then I create a toast mess
More easy way :
public class MyToast extends Toast {
public MyToast(Context context){
super(context)
this.setView(LayoutInflater.from(context).inflate(R.layout.activity_toast,null));
}
public void showMe(){
super.show();
}
public static MyToast myMakeText(Context con,String message,int duration) {
MyToast mts = new MyToast(con);
View view = mts.getView();
TextView messageArea = view.findViewById(R.id.toastTextView);
messageArea.setText(message);
mts.setDuration(duration);
return mts;
}}
So you will ask :
MyToast.myMakeText(this,"my message",7000).showMe();