如何在android中使用选择器从资源图像数组中选择项目

时间:2015-09-01 11:24:22

标签: android xml android-layout selector android-recyclerview

这是我的strings.xml

 <string-array name="image_ids">
    <item>@drawable/profie1</item>
    <item>@drawable/settings1</item>
    <item>@drawable/search1</item>
    <item>@drawable/history1</item>
    <item>@drawable/sharing1</item>
    <item>@drawable/alerts1</item>
    <item>@drawable/polls1</item>
    <item>@drawable/news1</item>
    <item>@drawable/support1</item>

</string-array>

    <string-array name="imageactive_ids">
    <item>@drawable/profileactive1</item>
    <item>@drawable/settingsactive1</item>
    <item>@drawable/searchactive1</item>
    <item>@drawable/historyactive1</item>
    <item>@drawable/sharingactive1</item>
    <item>@drawable/alertsactive1</item>
    <item>@drawable/pollsactive1</item>
    <item>@drawable/newsactive1</item>
    <item>@drawable/supportactive1</item>

</string-array>

这是我的selector.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_activated="true" android:drawable="@array/image_ids" />
<item android:state_selected="true" android:drawable="@array/image_ids" />
<item android:state_pressed="true" android:drawable="@array/image_ids" />
<item android:state_focused="true" android:drawable="@array/image_ids" />
<item android:drawable="@array/imageactive_ids" />

 </selector> 

我想将此选择器用于我的recyclerview图像项,但它提供了错误膨胀视图异常

我该怎么办请帮助我坚持几天。

0 个答案:

没有答案