Preface
This chapter is about android. widget. Checkable, translated from "CN 7". Thanks again "CN 7 "! Welcome to join 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 interface Checkable
Indirect subclass
CheckBox, CheckedTextView, CompoundButton, RadioButton, ToggleButton
Ii. Overview
This interface defines an extension so that the view control inherited from it has optional state attributes.
(Note: any class that inherits this interface has the android: checked attribute .)
Iii. Public Methods
Public abstract boolean isChecked ()
Query the selected status of the current view control.
Return Value:
Returns a boolean value to indicate the selected status of the current view control. If the current control is selected, the return value is true. Otherwise, the return value is false.
(Note: it is not necessarily that the control displays a right sign or a point that is selected, it is very likely that a programmer with a different thinking will define a right number as unselected and return a false value. Of course, this is only possible. In general sense, the right sign and point indicate true, and vice versa .)
Public abstract void setChecked (boolean checked)
Sets the selected status of the current view control. Note:
|
Before Execution |
Run |
After execution |
|
Any status |
SetChecked (true) |
Selected |
|
Any status |
SetChecked (false) |
Not selected |
Parameters:
Checked specifies that the control is selected in the "true" status, indicating that the control is set to selected, and "false" indicates that the control is not selected.
Public abstract void toggle ()
This method is used to switch the selected status of the current view control. (Note: Changes the current status of the View control to the opposite status .)
|
Before Execution |
Run |
After execution |
|
Selected |
Toggle () |
Not selected |
|
Not selected |
Toggle () |
Selected |
End
The author of this article is very careful and even somewhat touched. Let's take a look at the original article and then look at this article. The translator has added many notes that are easier to understand, thanks again to "CN 7" for providing excellent works!