Created an AlertDialog in which the .setView method adds a layout with EditText and buttons:
AlertDialog.Builder builder = new AlertDialog.Builder(HomeActivity.this); View view = HomeActivity.this.getLayoutInflater().inflate(R.layout.text_fields, null);
In the same layout on one of the buttons I hang up an event that should take the value of EditText .
Button code:
LayoutInflater factory = LayoutInflater.from(HomeActivity.this); View view = factory.inflate(R.layout.text_fields, null); EditText text = (EditText)view.findViewById(R.id.editText); System.out.println("Text of view: " + text.getText());
Displays either the default EditText value, if it is set, or empty, even though the EditText itself is filled.
Also if you register
text.setText("some text");
it displays some text.
Why when you click on the button does not display the value of EditText ?
upd
If you do this manipulation, but without Inflate and setting setViewContent(R.layout.text_fields)
, then everything is displayed. That is, I suppose the problem is that the ID EditText created in AlertDialog.Builder is missing.