Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Fields](https://developer.android.com/reference/android/util/StateSet#lfields) \| [Methods](https://developer.android.com/reference/android/util/StateSet#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/util/StateSet#inhmethods)

# StateSet

*** ** * ** ***

` public class StateSet `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.util.StateSet |

<br />

*** ** * ** ***

State sets are arrays of positive ints where each element represents the state of a `https://developer.android.com/reference/android/view/View` (e.g. focused, selected, visible, etc.). A `https://developer.android.com/reference/android/view/View` may be in one or more of those states. A state spec is an array of signed ints where each element represents a required (if positive) or an undesired (if negative) `https://developer.android.com/reference/android/view/View` state. Utils dealing with state sets. In theory we could encapsulate the state set and state spec arrays and not have static methods here but there is some concern about performance since these methods are called during view drawing.

## Summary

| ### Fields ||
|---|---|
| ` public static final int[]` | `https://developer.android.com/reference/android/util/StateSet#NOTHING` A state set that does not contain any valid states. |
| ` public static final int[]` | `https://developer.android.com/reference/android/util/StateSet#WILD_CARD` A state specification that will be matched by all StateSets. |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/util/StateSet#dump(int[])(int[] states) ` |
| ` static boolean` | ` https://developer.android.com/reference/android/util/StateSet#isWildCard(int[])(int[] stateSetOrSpec) ` Return whether the stateSetOrSpec is matched by all StateSets. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/StateSet#stateSetMatches(int[],%20int[])(int[] stateSpec, int[] stateSet) ` Return whether the stateSet matches the desired stateSpec. |
| ` static boolean` | ` https://developer.android.com/reference/android/util/StateSet#stateSetMatches(int[],%20int)(int[] stateSpec, int state) ` Return whether the state matches the desired stateSpec. |
| ` static int[]` | ` https://developer.android.com/reference/android/util/StateSet#trimStateSet(int[],%20int)(int[] states, int newSize) ` |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Fields

### NOTHING

Added in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int[] NOTHING
```

A state set that does not contain any valid states.

<br />

### WILD_CARD

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int[] WILD_CARD
```

A state specification that will be matched by all StateSets.

<br />

## Public methods

### dump

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String dump (int[] states)
```

<br />

<br />

| Parameters ||
|---|---|
| `states` | `int` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | <br /> |

### isWildCard

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean isWildCard (int[] stateSetOrSpec)
```

Return whether the stateSetOrSpec is matched by all StateSets.

<br />

| Parameters ||
|---|---|
| `stateSetOrSpec` | `int`: a state set or state spec. <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### stateSetMatches

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean stateSetMatches (int[] stateSpec, 
                int[] stateSet)
```

Return whether the stateSet matches the desired stateSpec.

<br />

| Parameters ||
|---|---|
| `stateSpec` | `int`: an array of required (if positive) or prohibited (if negative) `https://developer.android.com/reference/android/view/View` states. <br /> |
| `stateSet` | `int`: an array of `https://developer.android.com/reference/android/view/View` states <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### stateSetMatches

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static boolean stateSetMatches (int[] stateSpec, 
                int state)
```

Return whether the state matches the desired stateSpec.

<br />

| Parameters ||
|---|---|
| `stateSpec` | `int`: an array of required (if positive) or prohibited (if negative) `https://developer.android.com/reference/android/view/View` states. <br /> |
| `state` | `int`: a `https://developer.android.com/reference/android/view/View` state <br /> |

| Returns ||
|---|---|
| `boolean` | <br /> |

### trimStateSet

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int[] trimStateSet (int[] states, 
                int newSize)
```

<br />

<br />

| Parameters ||
|---|---|
| `states` | `int` <br /> |
| `newSize` | `int` <br /> |

| Returns ||
|---|---|
| `int[]` | <br /> |