Purpose: select an item and set its font to # 3197FF. If it is not selected, the font of the item is # FFFFFF.
Use selector like setting the selected row item background image in listvew. However, the color settings here should be set in textview in listview.Copy codeThe Code is as follows: <SPAN style = "COLOR: #666666"> <? Xml version = "1.0" encoding = "UTF-8"?>
<TableLayout
Xmlns: android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "wrap_content"
Android: layout_height = "wrap_content"
>
<TableRow>
<TextView
Android: id = "@ + id/name_ TV"
Android: layout_height = "wrap_content"
Android: layout_width = "wrap_content"
Android: textSize = "25px"
Android: textColor = "@ drawable/itemcolor">
</TextView>
</TableRow>
</TableLayout> </SPAN>
Similarly, define the itemcolor. xml file to modify the font color of the selected row:Copy codeThe Code is as follows: <SPAN style = "COLOR: #666666"> <? Xml version = "1.0" encoding = "UTF-8"?>
<Selector xmlns: android = "http://schemas.android.com/apk/res/android">
<! -- Font color without focus -->
<Item
Android: state_selected = "false"
Android: color = "# FFFFFF"/>
<! -- Font color when selected -->
<Item
Android: state_selected = "true"
Android: color = "# 3197FF"/>
<! -- Font color when the focus is obtained in non-touch mode and clicked -->
<Item
Android: state_focused = "true"
Android: state_pressed = "true"
Android: color = "# 3197FF"/>
</Selector> </SPAN>