Android Guides | Samples

Android.Graphics.Drawables.Drawable.SetState Method

Specify a set of states for the drawable.


[Android.Runtime.Register("setState", "([I)Z", "GetSetState_arrayIHandler")]
public virtual Boolean SetState (Int32[] stateSet)


The new set of states to be displayed.


Specify a set of states for the drawable. These are use-case specific, so see the relevant documentation. As an example, the background for widgets like Button understand the following states: [NoType:android/R$attr;Href=../../../../reference/android/R.attr.html#state_focused, NoType:android/R$attr;Href=../../../../reference/android/R.attr.html#state_pressed].

If the new state you are supplying causes the appearance of the Drawable to change, then it is responsible for calling Drawable.InvalidateSelf in order to have itself redrawn, and true will be returned from this function.

Note: The Drawable holds a reference on to stateSet until a new state array is given to it, so you must not modify this array during that time.

[Android Documentation]


Namespace: Android.Graphics.Drawables
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions:
Since: Added in API level 1