ToggleImageButton extends ImageButton { public void setToggledOn(boolean isToggledOn) { this.isToggledOn = isToggledOn; setContentDescription(isToggledOn ? contentDescriptionOn : contentDescriptionOff); refreshDrawableState(); } ToggleImageButton(Context context);  ToggleImageButton(Context context, AttributeSet attrs);  ToggleImageButton(Context context, AttributeSet attrs, int defStyle); @Override int[] onCreateDrawableState(int extraSpace); @Override boolean performClick(); void setToggledOn(boolean isToggledOn); void toggle(); boolean isToggledOn();  }
@Test public void testSetToggledOn() { final ToggleImageButton button = createDefaultButton(); assertFalse(button.isToggledOn()); button.setToggledOn(true); assertTrue(button.isToggledOn()); }