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
Toasts cannot be focused. Is this wrong, outdated, or did Gmail find a way around it?
The Gmail undo bar is’t a toast, here is how Google did it
I guess this answers your question.
What you’re referring to is not a Toast but what Google has dubbed a Snackbar. See the Material Design guidelines.
Currently, the most extensive, popular, and active one seems to be Snackbar by nispok, which I also happen to be using.
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.
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] : http://i.stack.imgur.com/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.