Reputation: 1029
First of all, I know this has been asked before: Button in custom Android Toast?. This is nearly an exact duplicate, but I think that it warrants a new question based on the fact that it's been used in apps, namely Gmail for ICS (it appears when you delete a message).
The linked question says that it's not possible to include a button in a Toast
because Toast
s cannot be focused. Is this wrong, outdated, or did Gmail find a way around it?
Upvotes: 19
Views: 10733
Reputation: 70
If you want a button in a toast, its better you quit that idea. But you can use dialogs in place of toast. Using dailogs, you will be able to display whatever you want (same function as a toast would do). Also in the dailog, you could set buttons.
Upvotes: 1
Reputation: 2654
What you're referring to is not a Toast but what Google has dubbed a Snackbar. See the Material Design guidelines.
You can find several implementations of this on GitHub. Some also go by the name of UndoBar
Currently, the most extensive, popular, and active one seems to be Snackbar by nispok, which I also happen to be using.
Upvotes: 2
Reputation: 8000
I have extended the UndoBar mentioned by @Hazem (link) and made it more generic so that it can be used for other actions also. You can have a look here.
Upvotes: 0
Reputation: 11
Gmail on iOS does provide a toast and it is a much better solution than interrupting the user flow with a dialog.
![Toast style message in Gmail for iOS][1] [1]: https://i.sstatic.net/LWClq.jpg
If you use this option, make sure the toast is displayed long enough for the user to tap undo if needed. So 5 seconds as opposed to 2.5-3 seconds in a info-only toast.
The other example cited by CommonsWare is the inline feedback which is shown after a swipe gesture. This is not a toast- but it is also a great way to provide feedback that an action has been performed.
Upvotes: 0
Reputation: 3790
The Gmail undo bar is't a toast, here is how Google did it
I guess this answers your question.
Upvotes: 36