나는 사용자로부터 텍스트 데이터를 얻을 수 있도록 EditText를 포함하는 커스텀 다이얼로그를 만들고있다.대화 상자 문제 : 콘텐츠를 추가하기 전에 requestFeature()를 호출해야합니다.
final EditText newKey = (EditText) findViewById(R.id.dialog_result);
AlertDialog.Builder keyBuilder = new AlertDialog.Builder(StegDroid.this);
keyBuilder
.setCancelable(false)
.setPositiveButton("Try Again", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Log.v("Dialog","New Key: "+newKey.getText().toString());
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog dialog = keyBuilder.create();
dialog.setTitle("Decryption Failed");
dialog.setContentView(R.layout.decrypt_failed_dialog);
dialog.show();
그러나 나는 항상이 예외를 가진다 :
01-11 18:49:00.507: ERROR/AndroidRuntime(3461): android.util.AndroidRuntimeException: requestFeature() must be called before adding content
01-11 18:49:00.507: ERROR/AndroidRuntime(3461): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:181)
01-11 18:49:00.507: ERROR/AndroidRuntime(3461): at com.android.internal.app.AlertController.installContent(AlertController.java:199)
01-11 18:49:00.507: ERROR/AndroidRuntime(3461): at android.app.AlertDialog.onCreate(AlertDialog.java:251)
...
dialog.show()
의 라인에서
. 이걸 없애기 위해 내가 무엇을해야합니까?
다른 사람이 코드를 비교할 필요없이 다르게 수행 된 것을 알아낼 수 있도록 주석을 추가하는 것이 좋을 것입니다. – codinguser
당신은 맞습니다 ... 지금 당장 시간이 없습니다. 더 정확한 답변을 편집 하시겠습니까? – Cristian
감사! "... 당신은 setContentView() ... 대신 setView (View)를 사용해야합니다.":) –