Dynamical pressed image for icon in android
I have an icon which has different images on different run and for each image on the icon there is another image corresponding to that image which is the images which has to be shown when it is pressed开发者_如何学编程. i.e. I want to change the pressed image of an icon programatically. IS there any way to do that. Help please.....
try this
img.xml
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true"
android:state_pressed="false"
android:drawable="@drawable/img_selected" />
<item android:state_focused="true"
android:state_pressed="true"
android:drawable="@drawable/img_selected" />
<item android:state_focused="false"
android:state_pressed="true"
android:drawable="@drawable/img_disabled" />
<item android:drawable="@drawable/img_selected" />
</selector>
and set background this xml for imageview
精彩评论