I have the following code:
private Toast movieRecordToast; private void displayNextMovie() { if (movieRecordToast != null) movieRecordToast.cancel(); // cancel previous Toast (if user changes movies too often) movieRecordToast = Toast.makeText(getApplicationContext(), "Next", Toast.LENGTH_SHORT); movieRecordToast.show(); private void displayPrevMovie() { if (movieRecordToast != null) movieRecordToast.cancel(); movieRecordToast = Toast.makeText(getApplicationContext(), "Prev", Toast.LENGTH_SHORT); movieRecordToast.show();
But if displayNextMovie is called quickly several times and then displayPrevMovie is displayPrevMovie , βNextβ Toast is still displayed and only then βPrevβ is displayed. Cancellation does not seem to work properly.
android toast
LA_ Mar 31 '11 at 17:16 2011-03-31 17:16
source share