Changing text color of list view in android

BIBEKRBARAL picture BIBEKRBARAL · Mar 1, 2010 · Viewed 40.1k times · Source

I am trying to change the text color of a listview in Android. Can anyone please give me a heads up on how it's done?

Answer

ranjit patel picture ranjit patel · May 11, 2012

Yes possible

please add a separate layout with the textview

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >


 <TextView
        android:id="@android:id/text1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:minHeight="?android:attr/listPreferredItemHeight"
        android:paddingLeft="6dip"
        android:textColor="@color/black"
        android:paddingRight="10dip"
        android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>

and change the **android.R.layout.simple_list_item_1** to and pass the textview id like this

new ArrayAdapter(this, R.layout.layoutfilename,*android.R.id.text1*,userList);