我在选择器xml文件上遇到以下异常,我已将其定义为自定义按钮的背景。
org.xmlpull.v1.XmlPullParserException: Binary XML file line #8: <item> tag requires a 'drawable' attribute or child tag defining a drawable
该文件如下:
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http//schemas.android.com/apk/res/com.toucans.negevsales">
<item
android:state_pressed="true"
app:state_expanded="false"
android:drawable="@drawable/plus_pressed" />
<item
android:state_pressed="false"
app:state_expanded="false"
android:drawable="@drawable/plus" />
<item
android:state_pressed="true"
app:state_expanded="true"
android:drawable="@drawable/minus_pressed" />
<item
android:state_pressed="false"
app:state_expanded="true"
android:drawable="@drawable/minus" />
</selector>
我错过了一些装饰吗?我按照this回答来创建我的自定义按钮,但图像没有切换,并且异常似乎在渲染时抛出,而不是在运行时抛出。这有什么不对?