Reputation: 4613
I see many developers choosing to theme their activity as a dialog instead of using the android dialog and customize it.
I searched on the internet for this answer but couldn't find it.
Could someone give me the pro's and con's of the activity theme method? Of course, it gives you more freedom but are there any styling reasons to avoid customizing the standard dialog?
I, myself needed to re-use fragments in dialogs so I created a themed activity to comfort my needs but now I'm running into trouble at retrieving results from the themed activity.
Thanks in advance. Bram
Upvotes: 4
Views: 1282
Reputation: 26547
A custom dialog is easier to create (you don't have to handle onCreate, onPause, screen rotations, ...), and have less overhead.
So you should use a custom dialog whenever you don't want to display something more complex than a dialog.
Upvotes: 1
Reputation: 4111
1) Start your activity using startActivityForResult.
2) Before you close your dialog-styled activity add needed data to intent extras and save it using SetResult(int, intent).
3) To process results add code to anActivityResult of parent activity that will retrieve data from saved intent.
no probs.
Yes, if you need to add heavy custom logic to your "dialog", then usage of styled activity is preferable. In case of simple alerts - use Dialog.
Upvotes: 1