开发者

ListView and its text color

I have CustomListView ,ie contain a background image and TextView,

When an item is selected i need to change the background image and font color, currently i can change the background of selected row of the listview using an xml, but i can't change the text color.

By default my text color is black when am clicking an item in listview i need to change the text color to white.

am using following layout for my customlistview

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent" 
    android:layout_height="29dp"
    android:id="@+id/appcategoryLinearLayout"
    android:background="@drawable/appcategorybg1"
    android:gravity="left|center_vertical"
    >
        <TextView
        android:gravity="left|center_vertical"
        android:text="fdsfsdfsdfdsfdsfdsf"
        android:paddingLeft="8dp"
        android:textSize="8dp"
        android:textColor="@color/b开发者_如何学JAVAlack"
        android:id="@+id/appCategoryNameTextView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>


The only way to write your own ListAdapter and write custom controls which would have the visual properties you define.


I am not sure if this will help you but you can do some thing like this

Use TextView variables as global

TextView t ;


lv.setOnItemClickListener(new OnItemClickListener()
    {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id)
        {
                if(t != null)
                {
                    //reset the color to black
                }
                LinearLayout lay = (LinearLayout)v;
                t = lay.getChildAt(0);
                //now set text to bold
        }
    };
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜