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
Did you call super.show()
within your override? It's likely that Toast.show()
is calling this, and your override is now making it so that the call doesn't happen.
What you'll probably need to do is something like this:
public class MyOwnToast extends Toast {
public MyOwnToast(Toast toast) {
//Code to initialize your toast from the argument toast
//Probably something like this:
this.setView(toast.getView());
this.setDuration(toast.getDuration());
//etc. for other get/set pairs in Toast
}
public static MyMakeText(Context context, CharSequence text, int duration) {
return new MyOwnToast(Toast.makeText(context, text, duration));
}
public void show() {
//Your show override code, including super.show()
}
}
Then, when you want to use it, do:
MyOwnToast.MyMakeText(activity, "Some text", Toast.LENGTH_LONG).show();
See the Toast docs as a reference when filling this out: http://developer.android.com/reference/android/widget/Toast.html