查看背景的选择器 - XmlPullParserException

时间:2011-09-15 19:17:38

标签: android

我需要在触摸事件中更改我的TextView的背景,所以我有TextView这样:

<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" />

@颜色/ 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 -->
    <item android:color="@color/text_color"/> <!-- default -->
</selector>

我得到这样的例外:

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

1 个答案:

答案 0 :(得分:1)

替换

android:color

android:drawable
选择器xml中的