I have a xml file for my android app.at this xml file there are some TableRows. I want when user touches each rows then color of row changes. i am new to android and got some code for this changing but those couldn't help me. I write these codes but I m not certain for accuracy at all.please help. I want when touched a row then its color changes to BLue. and when finger got out returns to default? But how?
enter code here <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- When selected, use blue color for bachground row -->
<item
android:state_pressed="true"
android:drawable="@drawable/item_backgroundcolor_blue" />
<!-- When not selected, use no color for bachground row -->
<item ?????????????????????????? />
this is "item_backgroundcolor_blue" in "drawable"
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<color android:color="@color/LightBlue"/>
</shape>
You can use something like this :
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:drawable="@color/holo_blue_overlay" />
<item android:state_focused="true" android:drawable="@color/holo_blue_overlay" />
<item android:state_selected="true" android:drawable="@color/holo_blue_overlay" />
<item android:drawable="@android:color/transparent" />
</selector>