user3086226
user3086226

Reputation: 93

Can you use an OnClickListener with a toast?

I want to show a toast - simple. The issue is I can't incorporate an OnClickListener for it. When I click on the toast I want to trigger an event.

Is it possible to use an OnClickListener with a toast?

Upvotes: 2

Views: 3554

Answers (4)

Adnan
Adnan

Reputation: 5075

No you can't. But to achieve same like functionality, you may use Crouton library instead of Toasts.

https://github.com/keyboardsurfer/Crouton

Upvotes: 4

vijay_t
vijay_t

Reputation: 786

No! certainly Not! A toast provides simple feedback about an operation in a small popup. If you want to get Click event consider using Dialog for it

Upvotes: 2

velis
velis

Reputation: 10025

Toast also has getView() and setView() methods which enable you to set the custom view and still keep the Toast functionality. You can set onClick listenet to your custom view

Upvotes: 1

SMR
SMR

Reputation: 6736

No you cant add listener to a Toast but you can create a custom view use it like Toast and implement onClickListener on it.

Upvotes: 1

Related Questions