Udostępnij za pośrednictwem


Drawable.SetState(Int32[]) Method

Definition

Specify a set of states for the drawable.

[Android.Runtime.Register("setState", "([I)Z", "GetSetState_arrayIHandler")]
public virtual bool SetState (int[] stateSet);
[<Android.Runtime.Register("setState", "([I)Z", "GetSetState_arrayIHandler")>]
abstract member SetState : int[] -> bool
override this.SetState : int[] -> bool

Parameters

stateSet
Int32[]

The new set of states to be displayed.

Returns

Returns true if this change in state has caused the appearance of the Drawable to change (hence requiring an invalidate), otherwise returns false.

Attributes

Remarks

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: [android.R.attr#state_focused, android.R.attr#state_pressed].

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

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

Java documentation for android.graphics.drawable.Drawable.setState(int[]).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to