When I searched about toast in stackoverflow I have found many things which were related to my problem.However none of them solved my problem. In my android app I am supposed to show many toasts after eachother.However when I try to do so, next toast waits for the current toast to finish. Even if I used cancel for toast , it seems to me it never works.Please offer me a exact solution.Thank you..
inflater = getLayoutInflater();
backgForToast=(ViewGroup) findViewById(R.id.toast_layout_root);
layout = inflater.inflate(R.layout.toastbackground,backgForToast);
textForToast = (TextView) layout.findViewById(R.id.text);
textForToast.setText(toastMessage);
toast.setGravity(Gravity.TOP|Gravity.LEFT, toastX2-90,toastY2-90);
toast.setView(layout);
toast.show();
Handler handler = new Handler();
long delay = 500;
handler.postDelayed(new Runnable() {
@Override
public void run() {
toast.cancel();
}
}, delay);
You need to create a
Toastobject withToast.makeTextbefore you cancancel()it.