[Android beginners] 4. RadioButton & CheckBox, androidradiobutton
Start Android
Today I learned about the functions and usage of Single-choice buttons and multiple-choice buttons.
The main purpose is to be more familiar with the control operation methods and common listeners.
1. Basic concepts of multiple choice buttons (CheckBox) 2. <CheckBox/> listeners with CheckBox3, OnClickListener, and OnCheckedChangeListener 1. Use the <CheckBox/> label in the XML file, you can create a CheckBox control in the Activity. 2. Use the CheckBox object in the code to indicate that common CheckBox methods include setOnCheckedChangeListener (), setOnClickListener (), setChecked (), getId (), and so on... 3. A listener of OnClickListener and OnCheckedChangeListener can be bound to multiple control objects OnClickListener OnClick (View v). Its parameter is the object that triggers the listener; OnCheckChangeListener's OnCheckedChanged (CompoundButton buttonView, boolean isChecked). The first parameter is the object that triggers the listener. The second parameter is the state of the object at this time. 1. Basic concepts of a radio button (RadioButton) one group of radio buttons can only be selected. 2. RadioGroup and RadioButton represent a group, and the latter is one of them. 3. The OnClickListener and OnCheckedChangeListener listeners are used to listen to the status of a Single-choice button group. 1) XML file: <RadioButton/> & <RadioGroup/> 2) code: RadioButton & RadioGroup 3) The OnClickListener and OnCheckedChangeListener listeners are usually operated in a way similar to multiple-choice button controls .. Finally, I found that I do not have the XML foundation. I still want to learn it. Who told me to switch from EE to CS...
How does android add four horizontal bars of RadioButton and reduce the size?
Add a property to RadioGroup: android: orientation =
In Android, how does one use RadioButton to set a four-column 12-row single-choice table?
In a RadioGroup, The RadioButton layout can only be vertical or horizontal. To set it to multiple rows, you need to use multiple radiogroups, then, you can set multiple radiogroups to select only one RadioGroup at the same time, which is similar to a RadioGroup, but you can arrange the RadioButton in the group in a way similar to Table Styles.
The following code sets multiple radiogroups to have only one function at the same time:
Private Boolean changeGroup = false;
Public void onCheckedChanged (RadioGroup group, int checkedId ){
If (group! = Null & checkedId>-1 & changeGroup = false ){
If (group = frequencyGroup1 ){
ChangeGroup = true;
FrequencyGroup2.clearCheck ();
FrequencyGroup3.clearCheck ();
ChangeGroup = false;
} Else if (group = frequencyGroup2 ){
ChangeGroup = true;
FrequencyGroup1.clearCheck ();
FrequencyGroup3.clearCheck ();
ChangeGroup = false;
} Else if (group = frequencyGroup3 ){
ChangeGroup = true;
FrequencyGroup1.clearCheck ();
FrequencyGroup2.clearCheck ();
ChangeGroup = false;
}
}
}