<ImageView
... android:clickable="true"
android:src="@drawable/favorite_button_selector"
android:onClick="favoriteClicked" />
res/drawable<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/favorite_active" android:state_selected="true"/>
<item android:drawable="@drawable/favorite_inactive" android:state_selected="false"/>
</selector>
To make this work though we need to explicitly call setSelected(boolean) somewhere in your class. The best place to do so is probably in the onClick handler (favoriteClicked in this case).
No hay comentarios:
Publicar un comentario