Question

Where should you put selector code, like this:

<?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>

Should I create new file in all drawable forlders and paste this code or should I just paste it in values folder? What to do?

Was it helpful?

Solution

Have the xml in the drawable folder res/drawable/myselector.xml. Then you can use it as @drawable/myselector. No need to create file in all drawable folders.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top