android.graphics.drawable
Class StateListDrawable
java.lang.Object
android.graphics.drawable.Drawable
android.graphics.drawable.DrawableContainer
android.graphics.drawable.StateListDrawable
- All Implemented Interfaces:
- Drawable.Callback
public class StateListDrawable
- extends DrawableContainer
Lets you assign a number of graphic images to a single Drawable and swap out the visible item by a string
ID value.
| Methods inherited from class android.graphics.drawable.DrawableContainer |
draw, getChangingConfigurations, getConstantState, getCurrent, getIntrinsicHeight, getIntrinsicWidth, getMinimumHeight, getMinimumWidth, getOpacity, getPadding, invalidateDrawable, onBoundsChange, onLevelChange, scheduleDrawable, selectDrawable, setAlpha, setColorFilter, setConstantState, setDither, setVisible, unscheduleDrawable |
| Methods inherited from class android.graphics.drawable.Drawable |
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromStream, createFromXml, createFromXmlInner, getBounds, getLevel, getState, getTransparentRegion, inflateWithAttributes, invalidateSelf, isVisible, resolveOpacity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setFilterBitmap, setLevel, setState, unscheduleSelf |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StateListDrawable
public StateListDrawable()
addState
public void addState(int[] stateSet,
Drawable drawable)
- Add a new image/string ID to the set of images.
- Parameters:
stateSet - - An array of resource Ids to associate with the image.
Switch to this image by calling setState().drawable - -The image to show.
isStateful
public boolean isStateful()
- Description copied from class:
Drawable
- Indicates whether this view will change its appearance based on state.
Clients can use this to determine whether it is necessary to calculate
their state and call setState.
- Overrides:
isStateful in class DrawableContainer
- Returns:
- True if this view changes its appearance based on state, false
otherwise.
- See Also:
Drawable.setState(int[])
onStateChange
protected boolean onStateChange(int[] stateSet)
- Description copied from class:
Drawable
- Override this in your subclass to change appearance if you recognize the
specified state.
- Overrides:
onStateChange in class DrawableContainer
- Returns:
- Returns true if the state change has caused the appearance of
the Drawable to change (that is, it needs to be drawn), else false
if it looks the same and there is no need to redraw it since its
last state.
inflate
public void inflate(Resources r,
XmlPullParser parser,
AttributeSet attrs)
throws XmlPullParserException,
IOException
- Overrides:
inflate in class Drawable
- Throws:
XmlPullParserException
IOException
getStateListState
StateListDrawable.StateListState getStateListState()
Please submit a feedback, bug or feature