Change ListView's textcolor

后端 未结 2 1582
自闭症患者
自闭症患者 2020-12-01 23:43

I am trying to change the text color of the ListView but I cant find how to do that..<

    listViewObject= (ListView) findVi         


        
相关标签:
2条回答
  • 2020-12-02 00:16

    Check these for more info:

    http://www.anddev.org/view-layout-resource-problems-f27/changing-listview-text-color-t14527.html

    Changing text color of list view in android

    Change Text Color in ListView

    Make a layout for your List items and bind that to a ListAdapter.

    0 讨论(0)
  • 2020-12-02 00:42

    The problem is that you are using the default list item layout "android.R.layout.simple_list_item_1". If you want to change the color of the text in the listview you must create your own list item layout with the correct text color.

    You could add this item to your layout folder:

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@android:id/text1"
            style="?android:attr/listItemFirstLineStyle"
            android:paddingTop="2dip"
            android:paddingBottom="3dip"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:textColor="#FF0000" /> 
    

    Then pass this item instead of android.R.layout.simple_list_item_1

    0 讨论(0)
提交回复
热议问题