Preface
This chapter is about android. widget. CheckedTextView. The version is Android 2.2 r1. The translation is from Xiaoyi. Thank you again! I look forward to your participation in Android API Chinese translation, contact me over140@gmail.com.
Statement
You are welcome to repost, but please keep the original source of the article :)
Blog Garden: http://www.cnblogs.com/
Android Chinese translation group: http://www.cnblogs.com/over140/
Body
I. Structure
Public class CheckedTextView extends TextView implements Checkable
Java. lang. Object
Android. view. View
Android. widget. TextView
Android. widget. CheckedTextView
Ii. Overview
The class CheckedTextView inherits TextView and implements the Checkable interface. This class is useful when the setChoiceMode method of ListView is set to CHOICE_MODE_SINGLE or CHOICE_MODE_MULTIPLE instead of CHOICE_MODE_NONE.
Iii. Public Methods
Public boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)
Send an auxiliary event when building the sub-view. (Note: The Source Code shows that the selected status is set during View Construction .)
Parameters
Event
Return Value
Returns true if event processing is complete.
Public boolean isChecked ()
Select or not.
Public void setCheckMarkDrawable (Drawable d)
Sets the check mark for a given Drawable. Draw when isChecked () is true
Parameters
D. Check the Drawable of the tag.
Public void setCheckMarkDrawable (int resid)
Sets the check mark for a given Drawable and uses its resource id to identify it. Draw when isChecked () is true
Parameters
Resid is used to check the marked Drawable
Public void setChecked (boolean checked)
Change the selected status of the Text View
Parameters
If the checked text is selected, true is returned. If not selected, false is returned.
Public void setPadding (int left, int top, int right, int bottom)
Set the margins. The view may add some necessary space for displaying the scroll bar and depending on the type and visibility of the scroll bar. Therefore, the set value is used to call back getPaddingLeft (), getPaddingTop (), getPaddingRight (), and getPaddingBottom (). Different values are returned.
Parameters
Left margin (in pixels)
Top margin (in pixels)
Right margin (in pixels)
Bottom margin of bottom (in pixels)
Public void toggle ()
Returns the selected status of the current view.
Iv. Supplement
4.1 article link
Something about CheckedTextView
Android API CheckedTextView code demonstration
CheckedTextView display problems
4.2 Sample Code
For implementation code, see articles 1 and 2, or click here to download the code.