public void showEditPassword(){
LayoutInflater li = LayoutInflater.from(this);
View promptsView = li.inflate(R.layout.dialog_editpassword, null);
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
// set prompts.xml to alertdialog builder
alertDialogBuilder.setView(promptsView);
final EditText txtOldPass, txtNewPass, txtConfirmPass;
txtOldPass = (EditText) promptsView.findViewById(R.id.txtOldPassword);
txtNewPass = (EditText) promptsView.findViewById(R.id.txtNewPassword);
txtConfirmPass = (EditText) promptsView.findViewById(R.id.txtConfirmPassword);
// set and show dialog edit password
alertDialogBuilder.setCancelable(false)
.setPositiveButton("SAVE",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
//do the saving here
saveNewPassword(currentPassword, txtOldPass.getText().toString(),
txtNewPass.getText().toString(), txtConfirmPass.getText().toString());
//recreate();
Toast.makeText(MainActivity.this, "Save Password clicked", Toast.LENGTH_LONG);
}
})
.setNegativeButton("CANCEL",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
我想调用输入对话框并在单击时捕获保存按钮操作。我在对话框中单击了保存按钮时尝试添加Toast消息,但没有发生任何事情。感谢。
答案 0 :(得分:0)
您不能在show()
上致电Toast
。这就是为什么看起来什么也没发生