-1

I have a list view where I have 2 lines for every item. That looks like so:

Title of item1

Subtitle of item1

I was wondering if there is a way to change the color and size of the 2nd line by code?
They both share 1 TextView so I can't just edit that. I could use 2 text views but I'm not sure how to set that up.
I am using a custom xml for the list view though.

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal">

Here is my custom list view xml:

<RelativeLayout android:id="@+id/linearLayout1" 
android:layout_width="wrap_content" 
android:layout_height="match_parent" 
android:layout_margin="7dip">

    <TextView
        android:id="@+id/label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Medium Text"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="#474747"
         />
 </RelativeLayout>

</LinearLayout>

Here is how I'm assigning the xml to the list view:

    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,R.layout.row, R.id.label, arrayList);
    lv.setAdapter(arrayAdapter); 
GAMA
  • 5,958
  • 14
  • 79
  • 126
Dave
  • 407
  • 4
  • 17
  • 1
    You really should have two text views in each list item. You can create custom adapter and set details of each text view for an item. – Aleks G Jun 22 '12 at 12:22
  • [style Text View with Multiple values](http://stackoverflow.com/questions/1529068/is-it-possible-to-have-multiple-styles-inside-a-textview) – Muhammad Saifuddin Jun 22 '12 at 12:37

1 Answers1

0

you can use ArrayAdapter with tow Textview

Using simple_list_item_2 with an ArrayAdapter

as in link

and as per link you 'll get the text View using row.getText1(), row.getText2() so you can set the color their

or

can use custom Adapter as in link

Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36