Button in custom Android Toast?

前端 未结 8 1064
天命终不由人
天命终不由人 2020-11-30 06:01

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\

8条回答
  •  有刺的猬
    2020-11-30 06:23

    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.

提交回复
热议问题