开发者

How to create sub AlertDialog/Dialog box in Android?

开发者 https://www.devze.com 2023-03-29 14:08 出处:网络
I need to develop a menu in Android, so for that I am using AlertDialog. But the problem that I am getting is that , how do I develop menu with sub AlertDialog/Dialog. I hope the picture will make eve

I need to develop a menu in Android, so for that I am using AlertDialog. But the problem that I am getting is that , how do I develop menu with sub AlertDialog/Dialog. I hope the picture will make everything clear. And in the same time the Dialog should have back button so that if a user desires he would be able to move to the first开发者_Python百科 menu. Thanks

How to create sub AlertDialog/Dialog box in Android?


How about this - when you create AlertDialog 2, pass in the context of AlertDialog 1, using dialog.getContext() (instead of, say, passing in the original Activity).. and so on? I believe that would make AlertDialog 2 "appear over" AlertDialog 1. Cancelling dialog 2 or pressing back button should take you back to dialog 1.

You could extend the same notion to dialog 3 (i.e, pass in the context of dialog 2 while creating dialog 3) .. and so on.


why dialogs?

i think, it is possible to call multiple dialogs.

but i would suggest (though unconventional) you can have PreferenceActivity which can nest menus. remember setting pages.

and for blocking the main UI (if you want) you can invoke the activity with a dialog theme.

this will be easier to code and maintain. and you can have your back button as well.

you can call activity for result and get the result in the main activity.

0

精彩评论

暂无评论...
验证码 换一张
取 消