Radiobuuton is a radio button, and a checkbox is a check button.
RadioButton use, the first to put RadioButton in Radiogroup, Radiogroup is a button group, if you do not put Radliobutton inside, will lose the function of the radio.
Determine which button was selected
Group.setoncheckedchangelistener (New Radiogroup.oncheckedchangelistener () {
@Override
public void OnCheckedChanged (radiogroup group, int checkedid) {
if (rman.getid () = = Checkedid) {
LOG.D ("Mainactivty", Rman.gettext (). toString ());
} else if (rwaman.getid () = = Checkedid) {
LOG.D ("Mainactivty", Rwaman.gettext (). toString ());
}
}
});
checkbox is a multi-select button user can choose multiple
Determine which buttons to select based on the inner class implementation
Class Lisetdemo implements View.onclicklistener {
public void OnClick (view view) {
Boolean isChecked = ((Compoundbutton) view). isChecked ();
Switch (View.getid ()) {
Case R.id.checkbox:
if (isChecked) {
LOG.D ("Mainactivty", Game.gettext (). toString ());
}
else {
LOG.D ("Mainactivty", "not point on");
}
Break
Case R.ID.CHECKBOX2:
if (isChecked) {
LOG.D ("Mainactivty", Swing.gettext (). toString ());
}
else {
LOG.D ("Mainactivty", "not point on");
}
Break
Case R.ID.CHECKBOX3:
if (isChecked) {
LOG.D ("Mainactivty", Sing.gettext (). toString ());
}
else {
LOG.D ("Mainactivty", "not point on");
}
Break
}
}
}
RadioButton and checkbox for Android learning