0

How can do I show an AlertDialog when showing another.

more: I have an AlertDialog named for easy refrence DeviceDialog another one is ExitDialog

I call show on ExitDialog when DeviceDialog is showing after that, automatically DeviceDialog hides or dismissed or cancled (I don't know which)

How can do I prevent that or reShow DeviceDialog after ExitDialog hides

Hossain Khademian
  • 1,616
  • 3
  • 19
  • 29
  • 1
    Pretty sure you can't show more than on dialog at a time. You should create a more generic dialog, and then switch the view inside of it if you need it to show something different. – Falmarri Oct 08 '14 at 21:05
  • I test two simple Dialogs (not AlertDialog) and I can have multi opened Dialog in the activity. but I can't do that for AlertDialogs – Hossain Khademian Oct 08 '14 at 21:12

2 Answers2

1

I solve that

basicly when you call setButton the button first dismiss/cancel dialog and then call your code

simply I add

alertDialog.getButton(AlertDialog.BUTTON_<POSITIVE/NEGATIVE/..>).setOnClickListener(new View.OnClickListener() {
    ...
});

for each button I want in alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { ... }); after I create the dialog

Now the dialog doesn't hide(dismiss/..) after click buttons So I can show new AlertDialogs on this AlertDialog

Hossain Khademian
  • 1,616
  • 3
  • 19
  • 29
0

Don't show ExitDialog if DeviceDialog is showing

if (!DeviceDialog.isShowing())
{
    ExitDialog.show();
}
ToYonos
  • 16,469
  • 2
  • 54
  • 70
  • AlertDialog are modal dialogs, it's not possible to show both at the same time – ToYonos Oct 08 '14 at 21:14
  • It's necessary for my app to prevent DeviceDialog to closed automatically because it controls my app data security – Hossain Khademian Oct 08 '14 at 21:14
  • How can do I change a simple Dialog to Have AlertDialog|ProgressDialog Buttons (I just use AlertDialogs because of theme to create normal dialogs for my apps) – Hossain Khademian Oct 08 '14 at 21:17
  • Maybe this will prevent the dialog dismissal DeviceDialog.setCancelable(false); – ToYonos Oct 08 '14 at 21:19
  • I set that. If AlertDialogs are modal no code can stop this action. How can do I add normal (official!) Buttons for simple Dialogs – Hossain Khademian Oct 08 '14 at 21:21
  • I guess you will have to write your own custom Dialog indeed. This will help http://stackoverflow.com/questions/13341560/how-to-create-a-custom-dialog-box-in-android – ToYonos Oct 08 '14 at 21:26