Android listview changes the font color of the selected row

Source: Internet
Author: User

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>

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.