Search code examples
javaandroidlayouttextviewsettext

Get access to setText to a view that is not in the default XML layout


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.


Solution

  • use following code:

        LayoutInflater inflater = getLayoutInflater();
        View view = inflater.inflate(R.layout.popup_window, null);
        TextView tv = (TextView)view.findViewById(R.id.yourTextID);
        tv.setText()