GAMA
GAMA

Reputation: 5996

Show AlertDialog on top of another AlertDialog

I'm taking some personal details from user in a form which is actually a custom Alertdialog. Now when user presses Submit button present within the Alertdialog, if there is an validation error; I'm trying to display another Alertdialog with error message like Please Enter First Name.

What is happening is when 2nd Alertdialog is being displayed due to a validation error, the main Alertdialog (registration form) gets disappeared.

Any reason what might me causing this. Any help appreciated.

Edit

Please note that I have considered setError but I also have some other views like Spinner, RadioButton in my layout. So just using setError for EditText is not whole solution for my problem.

Upvotes: 1

Views: 1248

Answers (2)

Salman Khakwani
Salman Khakwani

Reputation: 6714

If displaying another dialog on the existing dialog is your Application's requirement then, i would recommend you to create a new activity just for displaying that custom alert dialog. Add that activity to your Manifest and set the theme to "@android:style/Theme.Dialog".

<activity android:theme="@android:style/Theme.Dialog" android:name="LocationDialog"> </activity>

and onClick listener of your Dialog Interface just start the dialog activity for displaying the validation error.

 public void onClick(DialogInterface arg0, int arg1) {
         Intent errorDialog = new Intent(YourActivity.this, ErrorDialogActivity.class);
         startActivity(errorDialog);
  }

Upvotes: 1

alosdev
alosdev

Reputation: 394

you can make the validation before dismissing the dialogue and setErrorText on the edittexts, so it is visible to the user, without leaving the view.

Upvotes: 1

Related Questions