0

In ExpandableListView I have custom parent row (LinearLayout) which contains row data (in TextView with id=data) andwhen is pressed (state before expanded) I change color of row. How to change color of text when is pressed ? I can in adapter set when is expanded and when is not pressed, but I cannot fetch when is only pressed.

Damir
  • 54,277
  • 94
  • 246
  • 365

1 Answers1

0

You can set a selector as background of your LinearLayout :

Save this in /drawable/list_selector.xml :

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@android:color/holo_blue_bright" android:state_pressed="true"/>
    <item android:drawable="@android:color/holo_blue_light" android:state_selected="true"/>
    <item android:drawable="@android:color/holo_blue_dark" android:state_activated="true"/>
</selector>

And set it as background. Note that you can of course change the color as much as you want ;)

Arnaud
  • 509
  • 5
  • 13