Get Android View Instance

This is a stupid question, and I know that the answer is in front of me, I just have problems finding it in the right direction.

I have a custom view that has been configured as a content view and inflated from xml. How can I access an instance to call methods on it from an activity class? I remember returning to getResourceById () for a while, but now I can’t find it, and I'm not even sure if this is the best way to do this.

Sorry for the dumb question.

+4
source share
1 answer

If you used an inflator, you will be provided with an instance of the View class. Then you use your instance like this

LayoutInflater li = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = li.inflate(R.layout.small_listview_row, null); TextView tvItemText = (TextView)row.findViewById(R.id.tvItemText); 
+8
source

All Articles