Stay organized with collections
Save and categorize content based on your preferences.
StateSet
open class StateSet
State sets are arrays of positive ints where each element represents the state of a android.view.View
(e.g. focused, selected, visible, etc.). A 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) 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
Public methods |
open static String! |
|
open static Boolean |
Return whether the stateSetOrSpec is matched by all StateSets.
|
open static Boolean |
Return whether the state matches the desired stateSpec.
|
open static Boolean |
Return whether the stateSet matches the desired stateSpec.
|
open static IntArray! |
|
Properties |
static IntArray! |
A state set that does not contain any valid states.
|
static IntArray! |
A state specification that will be matched by all StateSets.
|
Public methods
isWildCard
open static fun isWildCard(stateSetOrSpec: IntArray!): Boolean
Return whether the stateSetOrSpec is matched by all StateSets.
Parameters |
stateSetOrSpec |
IntArray!: a state set or state spec. |
stateSetMatches
open static fun stateSetMatches(
stateSpec: IntArray!,
state: Int
): Boolean
Return whether the state matches the desired stateSpec.
stateSetMatches
open static fun stateSetMatches(
stateSpec: IntArray!,
stateSet: IntArray!
): Boolean
Return whether the stateSet matches the desired stateSpec.
Properties
NOTHING
static val NOTHING: IntArray!
A state set that does not contain any valid states.
WILD_CARD
static val WILD_CARD: IntArray!
A state specification that will be matched by all StateSets.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# StateSet\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nStateSet\n========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/util/StateSet \"View this page in Java\") \n\n```\nopen class StateSet\n```\n\n|---|----------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.util.StateSet](#) |\n\nState sets are arrays of positive ints where each element represents the state of a [android.view.View](../view/View.html#) (e.g. focused, selected, visible, etc.). A [android.view.View](../view/View.html#) 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) [android.view.View](../view/View.html#) 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.\n\nSummary\n-------\n\n| Public methods ||\n|----------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open static [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)! | [dump](#dump(kotlin.IntArray))`(`states:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!`)` \u003cbr /\u003e |\n| open static [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [isWildCard](#isWildCard(kotlin.IntArray))`(`stateSetOrSpec:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!`)` Return whether the stateSetOrSpec is matched by all StateSets. |\n| open static [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [stateSetMatches](#stateSetMatches(kotlin.IntArray,%20kotlin.Int))`(`stateSpec:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!`, `state:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Return whether the state matches the desired stateSpec. |\n| open static [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [stateSetMatches](#stateSetMatches(kotlin.IntArray,%20kotlin.IntArray))`(`stateSpec:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!`, `stateSet:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!`)` Return whether the stateSet matches the desired stateSpec. |\n| open static [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)! | [trimStateSet](#trimStateSet(kotlin.IntArray,%20kotlin.Int))`(`states:` `[IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!`, `newSize:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` \u003cbr /\u003e |\n\n| Properties ||\n|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|\n| static [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)! | [NOTHING](#NOTHING:kotlin.IntArray) A state set that does not contain any valid states. |\n| static [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)! | [WILD_CARD](#WILD_CARD:kotlin.IntArray) A state specification that will be matched by all StateSets. |\n\nPublic methods\n--------------\n\n### dump\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun dump(states: IntArray!): String!\n``` \n\n### isWildCard\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun isWildCard(stateSetOrSpec: IntArray!): Boolean\n```\n\nReturn whether the stateSetOrSpec is matched by all StateSets.\n\n| Parameters ||\n|------------------|--------------------------------------------------------------------------------------------------------------------|\n| `stateSetOrSpec` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!: a state set or state spec. |\n\n### stateSetMatches\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun stateSetMatches(\n stateSpec: IntArray!, \n state: Int\n): Boolean\n```\n\nReturn whether the state matches the desired stateSpec.\n\n| Parameters ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `stateSpec` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!: an array of required (if positive) or prohibited (if negative) [android.view.View](../view/View.html#) states. |\n| `state` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): a [android.view.View](../view/View.html#) state |\n\n### stateSetMatches\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun stateSetMatches(\n stateSpec: IntArray!, \n stateSet: IntArray!\n): Boolean\n```\n\nReturn whether the stateSet matches the desired stateSpec.\n\n| Parameters ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `stateSpec` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!: an array of required (if positive) or prohibited (if negative) [android.view.View](../view/View.html#) states. |\n| `stateSet` | [IntArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int-array/index.html)!: an array of [android.view.View](../view/View.html#) states |\n\n### trimStateSet\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen static fun trimStateSet(\n states: IntArray!, \n newSize: Int\n): IntArray!\n```\n\nProperties\n----------\n\n### NOTHING\n\nAdded in [API level 11](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val NOTHING: IntArray!\n```\n\nA state set that does not contain any valid states. \n\n### WILD_CARD\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val WILD_CARD: IntArray!\n```\n\nA state specification that will be matched by all StateSets."]]