Question about defining selector drawable

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Question about defining selector drawable

Postby silverburgh.meryl » Sat Feb 14, 2009 6:59 pm

Hi,

I am trying to setup a selector drawable in my asset file like this:
* 2 different images for 'on'/'off' mode in rest mode (i.e. it does
not has focus)
* another 2 different images for 'on'/'off' mode in focus mode (i.e.
it has the focus).

In my case, the rest mode works, but the 'focus' mode does not.

Can you please tell me what am I missing in the focus mode? Thank you.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- these 2 images works --->
<item android:state_checked="false" android:drawable="@drawable/off" />
<item android:state_checked="true" android:drawable="@drawable/on" />


<!-- these 2 images does not work -->
<item android:state_focused="true" android:state_checked="false"
android:drawable="@drawable/off_focus" />
<item android:state_focused="true" android:state_checked="true"
android:drawable="@drawable/on_focus" />

</selector>
silverburgh.meryl
Junior Developer
Junior Developer
 
Posts: 23
Joined: Sun Feb 08, 2009 11:17 pm

Top

Postby abraxas » Wed Feb 18, 2009 10:25 pm

You should try setting also the android:state_selected="true" attribute.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <item android:state_selected="true"
  2.  
  3. android:state_pressed="false"
  4.  
  5. android:drawable="@drawable/row_selected" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


This should do the trick!
abraxas
Junior Developer
Junior Developer
 
Posts: 20
Joined: Fri Feb 06, 2009 12:33 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 3 guests