I am using the Android SDK icon-button for refresh (ic_menu_refresh) in a widget and I need to change the selection state when it is pressed. How is this done? Do I define an XML for the button?
                +3 
                A: 
                
                
              You define the different states in xml via selector.
Sample (esp. see the state-attributes):
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/bg_catlocfilter" android:state_pressed="false" />
    <item android:drawable="@drawable/bg_catlocfilter_dark" android:state_pressed="true" />
    <item android:drawable="@drawable/bg_catlocfilter" android:state_focused="false" />
    <item android:drawable="@drawable/bg_catlocfilter_dark" android:state_focused="true" />
</selector>
                  Mathias Lin
                   2010-08-01 03:32:06
                
              Where do you get bg_catlocfilter?  Are they standard icons from android sdk?
                  mobibob
                   2010-08-01 05:03:59
                No, that's just an example from my app. You replace it with your icons (i.e. ic_menu_refresh) that you're using. You create one normal and one highlighted one.
                  Mathias Lin
                   2010-08-01 05:45:55
                OK.  I think I have it hooked up correctly, but there is no effect.  Does this work in widget (my guess is 'no').
                  mobibob
                   2010-08-01 19:21:05
                @mathias, my question was intended for widget, but I did not make that clear.  I accept your answer for the question I asked, but I need to re-ask as a widget.
                  mobibob
                   2010-08-02 13:30:48