How can I reference a drawable class in Android XML

Posted by James Veenstra on Stack Overflow See other posts from Stack Overflow or by James Veenstra
Published on 2010-04-30T18:09:48Z Indexed on 2010/05/01 17:57 UTC
Read the original article Hit count: 241

Filed under:

I've created a class that extends drawable that I'd like to reference inside a resource xml. I happen to need it in a selector, like so:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_pressed="false" 
android:drawable="com.sample.android.contacts.TopBarCollapsed"
/>
<item android:state_window_focused="true" android:state_pressed="true" android:drawable="@drawable/top_switcher_collapsed_selected" />
<item android:state_focused="true" android:drawable="@drawable/top_switcher_collapsed_focused" />

com.sample.android.contacts.TopBarCollapsed is the class that extends drawable.

© Stack Overflow or respective owner

Related posts about android