Question

This is a dumb question and I know the answer is sitting in front of me, I'm just having trouble searching for it in the right way.

I've got a custom view that has been set as the content view and inflated from xml. How can I access the instance to call methods on it from the activity class? I remember seeing something akin to getResourceById() a while back, but now I can't seem to find it and I'm not even sure if that's the best way to do it.

Sorry for the dumb question.

Was it helpful?

Solution

If you have used an inflater, you will be given an instance of a View class. You then use your instance like so

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top