私はAndroidを初めて使用し、このカスタムダイアログを機能させようとしています. showDialog
&removeDialog
でエラーが発生し、The method removeDialog(int)
is undefined for the type new DialogInterface.OnClickListener
.
onReceive
方法:
showDialog(DIALOG_TEXT_ENTRY);
コード:
private static final int MY_PASSWORD_DIALOG_ID = 0;
MediaPlayer mp;
Context context;
protected Dialog onCreateDialog(int id, Context context) {
Dialog dialog = null;
switch(id) {
case MY_PASSWORD_DIALOG_ID:
LayoutInflater factory = LayoutInflater.from(context);
final View textEntryView = factory.inflate(R.layout.password_dialog, null);
final EditText password1 = (EditText) textEntryView.findViewById(R.id.inputPassword);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("Enter Password");
builder.setView(textEntryView);
builder.setPositiveButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
removeDialog(MY_PASSWORD_DIALOG_ID);
}
});
AlertDialog passwordDialog = builder.create();
return passwordDialog;
}
return null;
}