I have a problem with a custom dialog.
My dialog consists of a TextView
, EditText
and an \"Ok\" Button. After clicking \"Ok\", it should get t
You are inflating a layout where it is not needed. I fixed your code as you see I removed your line where it inflates and changed the line where you try to find the EditText view.
final Dialog dialog = new Dialog(MyActivity.this);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Title");
Button button = (Button) dialog.findViewById(R.id.dialog_ok);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
EditText edit=(EditText)dialog.findViewById(R.id.dialog_edit);
String text=edit.getText().toString();
dialog.dismiss();
name=text;
}
});
dialog.show();