I have the following selector and it works pretty well.
<?xml version="1.0" encoding="utf-8"?>
<selector android:exitFadeDuration="@android:integer/config_mediumAnimTime"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/the_color" />
<item android:drawable="@android:color/transparent" />
</selector>
Note, I can use Color
for drawable, as in drawable-resouce.html
A color resource can also be used as a drawable in XML. For example, when creating a state list drawable, you can reference a color resource for the android:drawable attribute (android:drawable="@color/green").
Pretty good. Now, I want to try out theme.
home_menu_text_view_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector android:exitFadeDuration="@android:integer/config_mediumAnimTime"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="?attr/homeMenuTextViewPressedColor" />
<item android:drawable="@android:color/transparent" />
</selector>
attrs.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="homeMenuTextViewPressedColor" format="color" />
</resources>
themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.X.Light.DarkActionBar" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="homeMenuTextViewPressedColor">@color/home_menu_text_view_pressed_color_inverse_holo_light</item>
</style>
</resources>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="home_menu_text_view_pressed_color_inverse_holo_light">#ff4fc5f1</color>
</resources>
Now, I will getting the error :-
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line 4: tag requires a 'drawable' attribute or child tag defining a drawable
Any idea how I can resolve this?