我是 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;
}