Selector for View background - XmlPullParserException
I need the background for my TextView
was changed on touch event, so I have an TextView
like this:
<TextView android:id="@+id/tv_password_data"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@color/password_text"
style="@style/items_style" />
@color/password_text:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:color="@color/title_color"/> <!-- pressed -开发者_Python百科->
<item android:color="@color/text_color"/> <!-- default -->
</selector>
and I get exception like this:
09-15 22:06:02.120: ERROR/AndroidRuntime(21006): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: <item> tag requires a 'drawable' attribute or child tag defining a drawable
replace
android:color
with
android:drawable
in your selector xml.
精彩评论