I am trying to display a dialog from the onClick listener of a button of another dialog, but the 2nd dialog won't display. I searched and found a similar problem- Dialogs order in Android, tried the solution provided, but even that does not work.
My code is very similar to the one provided in the answer.
public void onClick(DialogInterface dialog, int id) { showDialog(SECOND_DIALOG); dialog.dismiss(); }
any help will be really appreciated.
Thanks,
Akshay
I know this was asked a while ago but here's a pretty neat solution I found.
I define an interface like this:
Which my activity then implements, passing a reference to itself to the dialog when it's opened, using my InterfaceHolder class:
InterfaceHolder is just a class with a static reference to the interface I use to pass it around:
So the showDialog method will display any dialog that I pass into it; as you can see, I do this to display DialogOne. Now, if I want to open a new dialog called "DialogTwo" inside "DialogOne" I can call it by writing:
And voila, DialogTwo is shown. Obviously, you have to be careful to ensure that a reference to your activity has been passed to the InterfaceHolder (a nice way to do this is to put InterfaceHolder.set(this); inside the showDialog method), but otherwise this seems to work beautifully.
my suggestion is this code. dialog 1 has a button when click it then dialog 2 will call.
Just Hide and Show Views On Dialog Clicks
This is how I'm doing it: