If you look at the source for simple_list_item_1, you'll see that it is just a TextView. The source is in:
<sdk-dir>/platforms/<your-platform>/data/res/layout/simple_list_item_1
The ArrayAdapter superclass will return that TextView in its getView method. That means you can subclass ArrayAdapter, and inside your subclass' getView method, you can simply chain to the superclass, cast the View it returns to TextView, and do your thing. For example, if you wanted to set the first three items in your list to textSize 24 and the rest to 14, you could do the following:
public View getView(int position, View convertView, ViewGroup parent) {
TextView tv = (TextView) super.getView(position, convertView, parent);
if (position < 3) {
tv.setTextSize(24.0f);
} else {
tv.setTextSize(14.0f);
}
return tv;
}
If you are using a more complicated View than simple_list_item_1, you can figure out the id's of the elements on the View by examining the source and then call findViewById on the View that is returned by the superclass. For example, two_line_list_item.xml has TextViews with ids of android.R.id.text1
and android.R.id.text2
, so you should be able to get a handle on them as follows:
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
TextView tv1 = (TextView)v.findViewById(android.R.id.text1);
TextView tv2 = (TextView)v.findViewById(android.R.id.text2);
//do what you want with the TextViews
}