Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the TextView ID in a simple_list_item_1 layout in Android?

Tags:

android

I have a custom ListView adapter that uses multiple layout types. One is the built-in type here:

v = inflater.inflate(android.R.layout.simple_list_item_1, null);

How do I access the TextView on that layout? What is the ID?

TextView txt1 = (TextView) v.findViewById(***WHAT IS THE ID***);
txt1.setText("foo");

And if you know the ID, how did you find it?

like image 825
Ethan Allen Avatar asked Dec 06 '12 21:12

Ethan Allen


1 Answers

It is @android:id/text1

So you need to modify your code like this

TextView txt1 = (TextView) v.findViewById(android.R.id.text1);

Found here https://github.com/android/platform_frameworks_base/blob/master/core/res/res/layout/simple_list_item_1.xml

Source code is your best friend!

like image 182
vasart Avatar answered Oct 21 '22 10:10

vasart