androidtoast

Event on toast hidden


I develop a game and want to show a dialog via toast : each sentence in different toast and showed one after other, but I can't find toast's event like on hide/on destroy. Can I make something like this with toast ?


Solution

  • There's no event for Toast messages, they're built into the actual operating system and you cannot control or customise them apart from the duration, position, layout and contents.

    If you fire multiple Toast messages one after the other they will be placed in a queue and the next one will be shown when the first one's duration finishes. In this way you could achieve what you want, however the system wasn't designed to do this. You should consider a View object in the view hierarchy that's on top of your other views to put your sentences in. This will allow you to have far more control over what you're showing the user as well as providing you with callbacks for when it is touched etc. This means that users can read the messages you're showing them at their own speed rather than only for the length of time you specify for a Toast duration.