Get nodes from a xml layout in Android

Using a layout template ex: temp.xml I’m creating a new View with LayoutInflater and I add that View to my MainActivity layout:

inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View newView = inflater.inflate(R.layout.temp, null, false);
mainActivLayout.addView(newView);

teml.xml has the following structure:

LinearLayout -> LinearLayout -> (two children) ImageView & TextView 

How do I extract from the newView the ImageView and TextView elements so I can add Text and a Image to them ?

Do I have to TypeCast newView to Node or NodeList?

Answer

You can use findViewById() on the newView

TextView textView = newView.findViewById(R.id.my_textview_id);
ImageView imageView = newView.findViewById(R.id.my_imageview_id);
Source: stackoverflow
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .