コードでエラーが発生し続けます。AlertDialog 内で新しい AlertDialog を呼び出そうとしています。サルトの表示に問題があるようですが、理由がわかりません...
public String passA = "";
public String passB = "";
public void createPassword() {
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
final AlertDialog.Builder salert = new AlertDialog.Builder(this);
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD
| InputType.TYPE_CLASS_TEXT);
salert.setView(input); // edit text added to alert
alert.setView(input); // edit text added to alert
salert.setTitle("Widerholen Sie Ihre PIN"); // title setted
alert.setTitle("Geben Sie eine PIN an"); // title setted
final OnClickListener b = new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
passB = input.getText().toString();
if (passA.equals(passB)) {
editor = settings.edit();
editor.putString("password", passA);
editor.commit();
logged_in = true;
return;
}
}
};
salert.setPositiveButton("OK", b);
OnClickListener a = new OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
passA = input.getText().toString();
salert.show();
return;
}
};
alert.setPositiveButton("OK", a);
alert.setOnCancelListener(new OnCancelListener() {
public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub
Functions.writeError("Falsche PIN Eingabe.");
finish();
}
});
alert.show();
}
私が得ているエラーは次のとおりです。
10-24 12:02:32.836: E/AndroidRuntime(2446): FATAL EXCEPTION: main
10-24 12:02:32.836: E/AndroidRuntime(2446): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.view.ViewGroup.addViewInner(ViewGroup.java:3337)
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.view.ViewGroup.addView(ViewGroup.java:3208)
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.view.ViewGroup.addView(ViewGroup.java:3188)
10-24 12:02:32.836: E/AndroidRuntime(2446): at com.android.internal.app.AlertController.setupView(AlertController.java:401)
10-24 12:02:32.836: E/AndroidRuntime(2446): at com.android.internal.app.AlertController.installContent(AlertController.java:241)
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.app.AlertDialog.onCreate(AlertDialog.java:336)
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.app.Dialog.dispatchOnCreate(Dialog.java:353)
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.app.Dialog.show(Dialog.java:257)
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.app.AlertDialog$Builder.show(AlertDialog.java:932)
10-24 12:02:32.836: E/AndroidRuntime(2446): at de.pixelstein.nativ.NativeTestActivity$5.onClick(NativeTestActivity.java:257)
10-24 12:02:32.836: E/AndroidRuntime(2446): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.os.Looper.loop(Looper.java:137)
10-24 12:02:32.836: E/AndroidRuntime(2446): at android.app.ActivityThread.main(ActivityThread.java:4514)
10-24 12:02:32.836: E/AndroidRuntime(2446): at java.lang.reflect.Method.invokeNative(Native Method)
10-24 12:02:32.836: E/AndroidRuntime(2446): at java.lang.reflect.Method.invoke(Method.java:511)
10-24 12:02:32.836: E/AndroidRuntime(2446): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
10-24 12:02:32.836: E/AndroidRuntime(2446): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
10-24 12:02:32.836: E/AndroidRuntime(2446): at dalvik.system.NativeStart.main(Native Method)
ヘルプや情報は役に立ちます。