core-ktx / androidx.content / android.content.Context

Extensions for android.content.Context

systemService

fun <T> Context.systemService(): T

Return the handle to a system-level service by class.

withStyledAttributes

fun Context.withStyledAttributes(set: AttributeSet? = null, attrs: IntArray, defStyleAttr: Int = 0, defStyleRes: Int = 0, block: TypedArray.() -> Unit): Unit

Executes block on a TypedArray receiver. The TypedArray holds the attribute values in set that are listed in attrs. In addition, if the given AttributeSet specifies a style class (through the style attribute), that style will be applied on top of the base attributes it defines.

fun Context.withStyledAttributes(resourceId: Int, attrs: IntArray, block: TypedArray.() -> Unit): Unit

Executes block on a TypedArray receiver. The TypedArray holds the the values defined by the style resource resourceId which are listed in attrs.