I am trying to get the following state list to work. The idea is to create a white background.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_selected="true"
android:drawable="@android:color/transparent" />
<item android:state_selected="true" android:drawable="@android:color/transparent" />
<item android:state_pressed="true" android:state_selected="false"
android:drawable="@android:color/transparent" />
<item android:state_selected="false" android:drawable="@color/WHITE" />
</selector>
When I try and compile this I get the following error..
@color/transparent and @color.WHITE don't exist.
Do I need to define these somewhere and if so how ?
Thanks !
I think the only problem is you are referencing directly a color instead of an actual Drawable. Try creating a ColorDrawable first and use it in your StateListDrawable.
When creating a ColorStateList (which is different from StateListDrawable because it's a list of colors and not Drawables) you can directly use colors ...
You must use @android:color, otherwise it doesn't know where the color is defined.
android:background="@android:color/white"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With