Android Learning RadioButton and checkbox

Source: Internet
Author: User

Radiobuuton is a radio button, and a checkbox is a check button.

The use of RadioButton, first to put RadioButton in radiogroup ,radiogroup is a button group, if you do notput R Adliobutton inside, You will lose the feature of the single selection.

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 ( 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 LisetdemoImplements 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 at all.");
}
Break
Case R.id.CheckBox2:
if (isChecked) {
Log.D"Mainactivty",Swing.gettext (). toString ());
}
else {
Log.D"Mainactivty","Not at all.");
}
break;
case r.id.checkbox3:
if (isChecked) {
Log.d ( "mainactivty", sing.gettext (). toString ());
}
else {
Log. "Mainactivty", " ");
}
break;
}
}
}

Android Learning RadioButton and checkbox

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.