public abstract class

CheckedTextView

extends TextView
implements Checkable
java.lang.Object
   ↳ android.view.View
     ↳ android.widget.TextView
       ↳ android.widget.CheckedTextView

Class Overview

An extension to TextView that supports the Checkable interface. This is useful when used in a ListView where the it's setChoiceMode has been set to something other than CHOICE_MODE_NONE.

Summary

[Expand]
Inherited XML Attributes
From class android.widget.TextView
From class android.view.View
[Expand]
Inherited Constants
From class android.view.View
Public Constructors
CheckedTextView(Context context)
CheckedTextView(Context context, AttributeSet attrs)
CheckedTextView(Context context, AttributeSet attrs, int defStyle)
Public Methods
boolean isChecked()
void setCheckMarkDrawable(Drawable d)
Set the checkmark to a given Drawable.
void setCheckMarkDrawable(int resid)
Set the checkmark to a given Drawable, identified by its resourece id.
void setChecked(boolean checked)

Changes the checked state of this text view.

void setPadding(int left, int top, int right, int bottom)
Sets the padding.
void toggle()
Change the checked state of the view to the inverse of its current state
Protected Methods
void drawableStateChanged()
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.
int[] onCreateDrawableState(int extraSpace)
Generate the new Drawable state for this view.
void onDraw(Canvas canvas)
Implement this to do your drawing.
[Expand]
Inherited Methods
From class android.widget.TextView
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewTreeObserver.OnPreDrawListener
From interface android.widget.Checkable

Public Constructors

public CheckedTextView (Context context)

public CheckedTextView (Context context, AttributeSet attrs)

public CheckedTextView (Context context, AttributeSet attrs, int defStyle)

Public Methods

public boolean isChecked ()

public void setCheckMarkDrawable (Drawable d)

Set the checkmark to a given Drawable. This will be drawn when isChecked() is true.

Parameters
d The Drawable to use for the checkmark.

public void setCheckMarkDrawable (int resid)

Set the checkmark to a given Drawable, identified by its resourece id. This will be drawn when isChecked() is true.

Parameters
resid The Drawable to use for the checkmark.

public void setChecked (boolean checked)

Changes the checked state of this text view.

Parameters
checked true to check the text, false to uncheck it

public void setPadding (int left, int top, int right, int bottom)

Sets the padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from getPaddingLeft(), getPaddingTop(), getPaddingRight() and getPaddingBottom() may be different from the values set in this call.

Parameters
left the left padding in pixels
top the top padding in pixels
right the right padding in pixels
bottom the bottom padding in pixels

public void toggle ()

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

Protected Methods

protected void drawableStateChanged ()

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

Be sure to call through to the superclass when overriding this function.

protected int[] onCreateDrawableState (int extraSpace)

Generate the new 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 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.
Returns
  • Returns an array holding the current Drawable state of the view.

protected void onDraw (Canvas canvas)

Implement this to do your drawing.

Parameters
canvas the canvas on which the background will be drawn