0

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.

4

2 回答 2

1

您可以在关闭对话框之前进行验证,并在编辑文本上设置错误文本,因此它对用户可见,而无需离开视图。

于 2013-07-16T12:52:56.407 回答
1

如果在现有对话框上显示另一个对话框是您的应用程序的要求,那么我建议您创建一个新活动来显示该自定义警报对话框。将该活动添加到您的清单并将主题设置为“@android:style/Theme.Dialog”。

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

并且您的 Dialog Interface 的 onClick 侦听器只是启动用于显示验证错误的对话框活动。

 public void onClick(DialogInterface arg0, int arg1) {
         Intent errorDialog = new Intent(YourActivity.this, ErrorDialogActivity.class);
         startActivity(errorDialog);
  }
于 2013-07-16T12:58:45.090 回答