bkowalczyyk
bkowalczyyk

Reputation: 292

ColorStateList doesn't work

I am beginner in android, and of course i have a problem with ColorStateList. I want to set it to ListView, but it doesn't work, maybe someone know why?

it is declaration of TextView

<TextView
android:textColor="@color/text_color"
android:id="@+id/tv"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/in"
android:onClick="onClick"                
android:clickable="true"
android:duplicateParentState='true'/>

and content of text_color.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
          android:color="#ffff0000"/> <!-- pressed -->
    <item android:state_focused="true"
          android:color="#ff0000ff"/> <!-- focused -->
    <item android:color="#ff000000"/> <!-- default -->
</selector>

It is code from StackOverflow reply, should work :/

Upvotes: 2

Views: 823

Answers (1)

Sreejith B Naick
Sreejith B Naick

Reputation: 1188

Try by setting listview.setItemsCanFocus(true);

Upvotes: 1

Related Questions