views:

232

answers:

1

Is it possible to have a button in a Toast?

In theory, yes because you can build a custom Toast from a layout in XML, but I tried to put a button in it and couldn't get it to register the click. Did anyone manage to do something like that?

+2  A: 

A toast can not be clicked. It is not possible to capture a click inside a toast message. You will need to build a dialog for that. Look at Creating Dialogs for more info.

The API on the Toast class state that a toast will never receive the focus and because a toast is not a view there is no onClick message. I would assume that therefore childs of a Toast can not be clicked as well.

Janusz
That's what I thought too. Ok thanks for the explanation. I know for the Dialogs, I was just doing some tests.
Sephy