I\'m creating a custom dialog containing an EditText so that I can get text data from the user:
final EditText newKey = (EditText) findViewById(R.id.dialog_r
You need to set the custom view before creating the dialog. Also you need to use setView(View)
instead of setContentView()
if you are using the default positive and negative buttons provided for you by the AlertDialog
.
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();
}
});
keyBuilder.setTitle("Decryption Failed");
keyBuilder.setView(getLayoutInflater().inflate(R.layout.decrypt_failed_dialog, null));
AlertDialog dialog = keyBuilder.create();
dialog.show();