how to add buttons dynamically in Alert Box in And

2019-06-01 18:09发布

I am developing android application in which for validations, it displays messages with alert box. I wanted to add buttons dynamically according to certain conditions. I like ask how to do this? I searched on Google, but couldn't find any suitable solutions.

Any Suggestions are helpful. Thanks.

3条回答
男人必须洒脱
2楼-- · 2019-06-01 18:22

i got the answer, I used Command Design pattern with help of CommandWrapper.

The following link elaborate more precisely. link

Thank you for everyone for their suggestions.

查看更多
Luminary・发光体
3楼-- · 2019-06-01 18:32

if you know the possible buttons that could be displayed:

  • add them to your layout
  • use the visibility attributes to show or hide it them, according to your conditions. (How To)
查看更多
疯言疯语
4楼-- · 2019-06-01 18:34

You can use a DialogFragment to acheive it. Create your own dialog view and inflate it in the onCreateView() of the dialog fragment.

查看更多
登录 后发表回答