I want to .setText
to a view that is not in the default XML layout - activity_main.xml
.
For a better understanding, I have 2 layout's: activity_main.xml
and popup_window.xml
.
The TextView
is in the popup_window.xml
.
Get access to setText to a view that is not in the default XML layout
75 Views Asked by Eyal At
2
There are 2 best solutions below
0

LinearLayout ll = getLayoutInflater().inflate( R.layout.popup_window, null )
TextView tv = (TextView)ll.findViewById(R.id.my_text_view);
tv.setText("Your text here");
customView.addView(ll);
Or if you want to use that layout as content view for a dialog ( i assume) then add it this way:
dialog.setView(ll);
dialog.show();
<<<<< EDIT: >>>>>
Ok so if I understood from your comment, that layout is part of a predefined dialog. then simply:
TextView tv = (TextView) dialog.getContentView().findViewById(R.id.my_text_view);
tv.setText("My text here");
use following code: