Reprinted: http://www.cnblogs.com/Amandaliu/archive/2011/06/14/2080948.html
Use selector like setting the selected row item background image in listvew. However, the color settings here should be set in textview in listview.
<? 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>
Similarly, define the itemcolor. xml file to modify the font color of the selected row:
<? 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>