Dialog
の表示を処理する関数を作成しましたが、OnClickListener
を使用できません。私のコードで何が間違っているのですか?ダイアログ内のボタンにOnClickListenerを追加できません
は、ここに私の機能(あなたがonCreate()
でsetContentView()
を呼び出すことにより、設定した1)あなたのActivity
のレイアウトにView
を探しますActivity.findViewById()
を呼び出す
private void showInputDialog() {
final Dialog dialog=new Dialog(MainDashboard.this);
dialog.setContentView(R.layout.frg_dialog_change_pass);
btn_save_password=(Button) findViewById(R.id.btn_save_password);
btn_cancel_pass=(Button) findViewById(R.id.btn_cancel_pass);
edtOldpass=(EditText) findViewById(R.id.edtOldpass);
edtNewpass=(EditText) findViewById(R.id.edtNewpass);
edtConfirmpass=(EditText)findViewById(R.id.edtConfirmpass);
dialog.show();///Show the dialog.
btn_save_password.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainDashboard.this, "Success", Toast.LENGTH_SHORT).show();
dialog.cancel();
}
});
}