Added in API level 1

CheckedTextView


open class CheckedTextView : TextView, Checkable
kotlin.Any
   ↳ android.view.View
   ↳ android.widget.TextView
   ↳ android.widget.CheckedTextView

An extension to TextView that supports the Checkable interface and displays.

This is useful when used in a ListView where the setChoiceMode has been set to something other than CHOICE_MODE_NONE.

Summary

XML attributes
android:checkMark Drawable used for the check mark graphic.
android:checked Indicates the initial checked state of this text.
Inherited XML attributes
Inherited constants
Public constructors

CheckedTextView(context: Context!, attrs: AttributeSet!)

CheckedTextView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

CheckedTextView(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Unit

This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.

open CharSequence!

Return the class name of this object to be used for accessibility purposes.

open Drawable!

Gets the checkmark drawable

open BlendMode?

Returns the blending mode used to apply the tint to the check mark drawable, if specified.

open ColorStateList?

Returns the tint applied to the check mark drawable, if specified.

open PorterDuff.Mode?

Returns the blending mode used to apply the tint to the check mark drawable, if specified.

open Boolean

open Unit

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

open Unit

Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState.

open Unit
onRtlPropertiesChanged(layoutDirection: Int)

Called when any RTL property (layout direction or text direction or text alignment) has been changed.

open Parcelable?

Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state.

open Unit

Set the check mark to the specified drawable.

open Unit

Sets the check mark to the drawable with the specified resource ID.

open Unit

Specifies the blending mode used to apply the tint specified by setCheckMarkTintList(android.content.res.ColorStateList) to the check mark drawable.

open Unit

Applies a tint to the check mark drawable.

open Unit

Specifies the blending mode used to apply the tint specified by setCheckMarkTintList(android.content.res.ColorStateList) to the check mark drawable.

open Unit
setChecked(checked: Boolean)

Sets the checked state of this view.

open Unit
setVisibility(visibility: Int)

Set the visibility state of this view.

open Unit

Change the checked state of the view to the inverse of its current state

Protected methods
open Unit

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

open IntArray!

Generate the new android.graphics.drawable.Drawable state for this view.

open Unit
onDraw(canvas: Canvas)

Implement this to do your drawing.

open Boolean

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.

Inherited functions
Inherited properties

XML attributes

android:checkMark

android:checkMark
Drawable used for the check mark graphic.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:checked

android:checked
Indicates the initial checked state of this text.

May be a boolean value, such as "true" or "false".

Public constructors

CheckedTextView

Added in API level 1
CheckedTextView(context: Context!)

CheckedTextView

Added in API level 1
CheckedTextView(
    context: Context!,
    attrs: AttributeSet!)

CheckedTextView

Added in API level 1
CheckedTextView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

CheckedTextView

Added in API level 21
CheckedTextView(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

drawableHotspotChanged

Added in API level 21
open fun drawableHotspotChanged(
    x: Float,
    y: Float
): Unit

This function is called whenever the view hotspot changes and needs to be propagated to drawables or child views managed by the view.

Dispatching to child views is handled by dispatchDrawableHotspotChanged(float,float).

Be sure to call through to the superclass when overriding this function.
If you override this method you must call through to the superclass implementation.

Parameters
x Float: hotspot x coordinate
y Float: hotspot y coordinate

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

Return the class name of this object to be used for accessibility purposes. Subclasses should only override this if they are implementing something that should be seen as a completely new class of view when used by accessibility, unrelated to the class it is deriving from. This is used to fill in AccessibilityNodeInfo.setClassName.

getCheckMarkDrawable

Added in API level 16
open fun getCheckMarkDrawable(): Drawable!

Gets the checkmark drawable

Return
Drawable! The drawable use to represent the checkmark, if any.

getCheckMarkTintBlendMode

Added in API level 29
open fun getCheckMarkTintBlendMode(): BlendMode?

Returns the blending mode used to apply the tint to the check mark drawable, if specified.

Return
BlendMode? the blending mode used to apply the tint to the check mark drawable.
This value may be null.

getCheckMarkTintList

Added in API level 21
open fun getCheckMarkTintList(): ColorStateList?

Returns the tint applied to the check mark drawable, if specified.

Return
ColorStateList? the tint applied to the check mark drawable.
This value may be null.

getCheckMarkTintMode

Added in API level 21
open fun getCheckMarkTintMode(): PorterDuff.Mode?

Returns the blending mode used to apply the tint to the check mark drawable, if specified.

Return
PorterDuff.Mode? the blending mode used to apply the tint to the check mark drawable.
This value may be null.

isChecked

Added in API level 1
open fun isChecked(): Boolean
Return
Boolean The current checked state of the view

jumpDrawablesToCurrentState

Added in API level 11
open fun jumpDrawablesToCurrentState(): Unit

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

Also calls StateListAnimator.jumpToCurrentState() if there is a StateListAnimator attached to this view.
If you override this method you must call through to the superclass implementation.

onRestoreInstanceState

Added in API level 1
open fun onRestoreInstanceState(state: Parcelable!): Unit

Hook allowing a view to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState. This function will never be called with a null state.
If you override this method you must call through to the superclass implementation.

Parameters
state Parcelable!: The frozen state that had previously been returned by onSaveInstanceState.

onRtlPropertiesChanged

Added in API level 17
open fun onRtlPropertiesChanged(layoutDirection: Int): Unit

Called when any RTL property (layout direction or text direction or text alignment) has been changed. Subclasses need to override this method to take care of cached information that depends on the resolved layout direction, or to inform child views that inherit their layout direction. The default implementation does nothing.

Parameters
layoutDirection Int: the direction of the layout.
Value is one of the following:

onSaveInstanceState

Added in API level 1
open fun onSaveInstanceState(): Parcelable?

Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.

Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
If you override this method you must call through to the superclass implementation.

Return
Parcelable? Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save.

setCheckMarkDrawable

Added in API level 1
open fun setCheckMarkDrawable(d: Drawable?): Unit

Set the check mark to the specified drawable.

When this view is checked, the drawable's state set will include android.R.attr#state_checked.

Parameters
d Drawable?: the drawable to use for the check mark.
This value may be null.

setCheckMarkDrawable

Added in API level 1
open fun setCheckMarkDrawable(resId: Int): Unit

Sets the check mark to the drawable with the specified resource ID.

When this view is checked, the drawable's state set will include android.R.attr#state_checked.

Parameters
resId Int: the resource identifier of drawable to use as the check mark

setCheckMarkTintBlendMode

Added in API level 29
open fun setCheckMarkTintBlendMode(tintMode: BlendMode?): Unit

Specifies the blending mode used to apply the tint specified by setCheckMarkTintList(android.content.res.ColorStateList) to the check mark drawable. The default mode is PorterDuff.Mode.SRC_IN.

Parameters
tintMode BlendMode?: the blending mode used to apply the tint, may be null to clear tint

setCheckMarkTintList

Added in API level 21
open fun setCheckMarkTintList(tint: ColorStateList?): Unit

Applies a tint to the check mark drawable. Does not modify the current tint mode, which is PorterDuff.Mode.SRC_IN by default.

Subsequent calls to setCheckMarkDrawable(android.graphics.drawable.Drawable) will automatically mutate the drawable and apply the specified tint and tint mode using Drawable.setTintList(ColorStateList).

Parameters
tint ColorStateList?: the tint to apply, may be null to clear tint

setCheckMarkTintMode

Added in API level 21
open fun setCheckMarkTintMode(tintMode: PorterDuff.Mode?): Unit

Specifies the blending mode used to apply the tint specified by setCheckMarkTintList(android.content.res.ColorStateList) to the check mark drawable. The default mode is PorterDuff.Mode.SRC_IN.

Parameters
tintMode PorterDuff.Mode?: the blending mode used to apply the tint, may be null to clear tint

setChecked

Added in API level 1
open fun setChecked(checked: Boolean): Unit

Sets the checked state of this view.

Parameters
checked Boolean: true set the state to checked, false to uncheck

setVisibility

Added in API level 1
open fun setVisibility(visibility: Int): Unit

Set the visibility state of this view.

Parameters
visibility Int: One of VISIBLE, INVISIBLE, or GONE.
Value is one of the following:

toggle

Added in API level 1
open fun toggle(): Unit

Change the checked state of the view to the inverse of its current state

Protected methods

drawableStateChanged

Added in API level 1
protected open fun drawableStateChanged(): Unit

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

If the View has a StateListAnimator, it will also be called to run necessary state change animations.

Be sure to call through to the superclass when overriding this function.
If you override this method you must call through to the superclass implementation.

onCreateDrawableState

Added in API level 1
protected open fun onCreateDrawableState(extraSpace: Int): IntArray!

Generate the new android.graphics.drawable.Drawable state for this view. This is called by the view system when the cached Drawable state is determined to be invalid. To retrieve the current state, you should use getDrawableState.

Parameters
extraSpace Int: if non-zero, this is the number of extra entries you would like in the returned array in which you can place your own states.
Return
IntArray! Returns an array holding the current Drawable state of the view.

onDraw

Added in API level 1
protected open fun onDraw(canvas: Canvas): Unit

Implement this to do your drawing.

Parameters
canvas Canvas: the canvas on which the background will be drawn.
This value cannot be null.

verifyDrawable

Added in API level 1
protected open fun verifyDrawable(who: Drawable): Boolean

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

Be sure to call through to the super class when overriding this function.
If you override this method you must call through to the superclass implementation.

Parameters
who Drawable: This value cannot be null.
Return
Boolean boolean If true then the Drawable is being displayed in the view; else false and it is not allowed to animate.