org.hermit.android.widgets
Class MultistateImageButton

java.lang.Object
  extended by ImageButton
      extended by org.hermit.android.widgets.MultistateImageButton

public class MultistateImageButton
extends ImageButton

This class displays an image button which toggles or cycles through multiple states when clicked.


Constructor Summary
MultistateImageButton(Context context, AttributeSet attrs, int[] images)
          Create a multistate image button with a specified set of image resource IDs.
MultistateImageButton(Context context, int[] images)
          Create a multistate image button with a specified set of image resource IDs.
 
Method Summary
 int getState()
          Get the current state of this button.
 void setOnClickListener(OnClickListener l)
          Register a callback to be invoked when this view is clicked.
 void setState(int s)
          Set the current state of this button.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultistateImageButton

public MultistateImageButton(Context context,
                             int[] images)
Create a multistate image button with a specified set of image resource IDs.

Parameters:
context - Parent application.
images - Resource IDs of the images to use for each state.

MultistateImageButton

public MultistateImageButton(Context context,
                             AttributeSet attrs,
                             int[] images)
Create a multistate image button with a specified set of image resource IDs.

Parameters:
context - Parent application.
attrs - Layout attributes.
images - Resource IDs of the images to use for each state.
Method Detail

setOnClickListener

public void setOnClickListener(OnClickListener l)
Register a callback to be invoked when this view is clicked. If this view is not clickable, it becomes clickable. We override this here because we are using the parent class's listener slot for our own purposes.

Parameters:
l - The callback that will run.

getState

public int getState()
Get the current state of this button.

Returns:
The current state, as an index into the list of images.

setState

public void setState(int s)
Set the current state of this button.

Parameters:
s - State to set, as an index into the list of images.