我应该在哪里放置选择器代码



您应该在哪里放置选择器代码,例如:

<?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:state_checked="true" 
    android:drawable="@drawable/cbchk_blue"
    android:state_focused="false">
</item>
<item android:state_checked="true" 
    android:drawable="@drawable/cbchk_blue"
    android:state_focused="true">
</item>
<item android:state_checked="false" 
    android:drawable="@drawable/cbunchk_blue"
    android:state_focused="false">
</item>
<item android:state_checked="false" 
    android:drawable="@drawable/cbunchk_blue"
    android:state_focused="true">
</item>
</selector>

我应该在所有可绘制的forlders中创建新文件并粘贴此代码,还是应该将其粘贴到值文件夹中?该怎么办?

drawable文件夹res/drawable/myselector.xml中具有XML。然后,您可以将其用作@drawable/myselector。无需在所有可绘制的文件夹中创建文件。

最新更新