Register now for Android Dev Summit 2019!

androidx.core.content.res

Classes

ConfigurationHelper

Helper class which allows access to properties of Configuration in a backward compatible fashion.

ResourcesCompat

Helper for accessing features in android.content.res.Resources.

Extension functions summary

For android.content.res.TypedArray
Boolean
TypedArray.getBooleanOrThrow(@StyleableRes index: Int)

Retrieve the boolean value for the attribute at index or throws IllegalArgumentException if not defined.

Int
TypedArray.getColorOrThrow(@StyleableRes index: Int)

Retrieve the color value for the attribute at index or throws IllegalArgumentException if not defined.

ColorStateList
TypedArray.getColorStateListOrThrow(@StyleableRes index: Int)

Retrieve the color state list value for the attribute at index or throws IllegalArgumentException if not defined.

Float
TypedArray.getDimensionOrThrow(@StyleableRes index: Int)

Retrieve the dimension value for the attribute at index or throws IllegalArgumentException if not defined.

Int

Retrieve the dimension pixel offset value for the attribute at index or throws IllegalArgumentException if not defined.

Int

Retrieve the dimension pixel size value for the attribute at index or throws IllegalArgumentException if not defined.

Drawable
TypedArray.getDrawableOrThrow(@StyleableRes index: Int)

Retrieve the drawable value for the attribute at index or throws IllegalArgumentException if not defined.

Float
TypedArray.getFloatOrThrow(@StyleableRes index: Int)

Retrieve the float value for the attribute at index or throws IllegalArgumentException if not defined.

Typeface
TypedArray.getFontOrThrow(@StyleableRes index: Int)

Retrieve the font value for the attribute at index or throws IllegalArgumentException if not defined.

Int
TypedArray.getIntOrThrow(@StyleableRes index: Int)

Retrieve the integer value for the attribute at index or throws IllegalArgumentException if not defined.

Int
TypedArray.getIntegerOrThrow(@StyleableRes index: Int)

Retrieve the integer value for the attribute at index or throws IllegalArgumentException if not defined.

Int
TypedArray.getResourceIdOrThrow(@StyleableRes index: Int)

Retrieves the resource identifier for the attribute at index or throws IllegalArgumentException if not defined.

String
TypedArray.getStringOrThrow(@StyleableRes index: Int)

Retrieve the string value for the attribute at index or throws IllegalArgumentException if not defined.

Array<CharSequence>
TypedArray.getTextArrayOrThrow(@StyleableRes index: Int)

Retrieve the text array value for the attribute at index or throws IllegalArgumentException if not defined.

CharSequence
TypedArray.getTextOrThrow(@StyleableRes index: Int)

Retrieve the text value for the attribute at index or throws IllegalArgumentException if not defined.

R
TypedArray.use(block: (TypedArray) -> R)

Executes the given block function on this TypedArray and then recycles it.

Extension functions

getBooleanOrThrow

fun TypedArray.getBooleanOrThrow(@StyleableRes index: Int): Boolean

Retrieve the boolean value for the attribute at index or throws IllegalArgumentException if not defined.

getColorOrThrow

fun TypedArray.getColorOrThrow(@StyleableRes index: Int): Int

Retrieve the color value for the attribute at index or throws IllegalArgumentException if not defined.

getColorStateListOrThrow

fun TypedArray.getColorStateListOrThrow(@StyleableRes index: Int): ColorStateList

Retrieve the color state list value for the attribute at index or throws IllegalArgumentException if not defined.

getDimensionOrThrow

fun TypedArray.getDimensionOrThrow(@StyleableRes index: Int): Float

Retrieve the dimension value for the attribute at index or throws IllegalArgumentException if not defined.

getDimensionPixelOffsetOrThrow

@Dimension fun TypedArray.getDimensionPixelOffsetOrThrow(@StyleableRes index: Int): Int

Retrieve the dimension pixel offset value for the attribute at index or throws IllegalArgumentException if not defined.

getDimensionPixelSizeOrThrow

@Dimension fun TypedArray.getDimensionPixelSizeOrThrow(@StyleableRes index: Int): Int

Retrieve the dimension pixel size value for the attribute at index or throws IllegalArgumentException if not defined.

getDrawableOrThrow

fun TypedArray.getDrawableOrThrow(@StyleableRes index: Int): Drawable

Retrieve the drawable value for the attribute at index or throws IllegalArgumentException if not defined.

getFloatOrThrow

fun TypedArray.getFloatOrThrow(@StyleableRes index: Int): Float

Retrieve the float value for the attribute at index or throws IllegalArgumentException if not defined.

getFontOrThrow

fun TypedArray.getFontOrThrow(@StyleableRes index: Int): Typeface

Retrieve the font value for the attribute at index or throws IllegalArgumentException if not defined.

getIntOrThrow

fun TypedArray.getIntOrThrow(@StyleableRes index: Int): Int

Retrieve the integer value for the attribute at index or throws IllegalArgumentException if not defined.

getIntegerOrThrow

fun TypedArray.getIntegerOrThrow(@StyleableRes index: Int): Int

Retrieve the integer value for the attribute at index or throws IllegalArgumentException if not defined.

getResourceIdOrThrow

@AnyRes fun TypedArray.getResourceIdOrThrow(@StyleableRes index: Int): Int

Retrieves the resource identifier for the attribute at index or throws IllegalArgumentException if not defined.

getStringOrThrow

fun TypedArray.getStringOrThrow(@StyleableRes index: Int): String

Retrieve the string value for the attribute at index or throws IllegalArgumentException if not defined.

getTextArrayOrThrow

fun TypedArray.getTextArrayOrThrow(@StyleableRes index: Int): Array<CharSequence>

Retrieve the text array value for the attribute at index or throws IllegalArgumentException if not defined.

getTextOrThrow

fun TypedArray.getTextOrThrow(@StyleableRes index: Int): CharSequence

Retrieve the text value for the attribute at index or throws IllegalArgumentException if not defined.

use

inline fun <R> TypedArray.use(block: (TypedArray) -> R): R

Executes the given block function on this TypedArray and then recycles it.

See Also