Case study of Android radiogroup and radiobutton

Source: Internet
Author: User

Radiobutton consists of two parts: radiobutton and radiogroup. radiogroup is a single-choice combo box that can hold multiple radiobutton containers. radiobutton can be selected if no radiogroup exists. When multiple radiobutton instances are included in a radiogroup, only one radiobutton instance can be selected. Use setoncheckedchangelistener to listen to the radio button

 

Radiogroup attributes:

Radiogroup. getcheckedradiobuttonid (); -- get the ID of the selected button

Radiogroup. clearcheck (); // --- clear the selected state

Radiogroup. check (int id); // --- set this option to the selected status through the input option ID. If-1 is passed as the specified selection identifier, the check status of the single-choice button group is cleared, it is equivalent to calling the clearcheck () operation.

Setoncheckedchangelistener (radiogroup. oncheckedchangelistener listener); // a callback function to be called when the status of the single-choice button in the single-choice button group is changed

Addview (view child, int index, viewgroup. layoutparams Params); // --- add a subview using the specified layout Parameter

// Parameter child: the Child View index to be added the child view location Params the child view layout parameter to be added

Radiobutton. gettext (); // obtain the value of a single response

// In addition, the checked attribute of radiobutton is set to true. The check (ID) method of radiobutton is called in the Code and the oncheckedchanged event is not triggered.

 

The relationship between radiobutton and radiogroup:

1. radiobutton indicates a single circle, while radiogroup is a container that can hold multiple radiobutton.

2. Only one radiobutton in each radiogroup can be selected.

3. radiobutton in different radiogroups is irrelevant. That is, if one of group A is selected, one of group B can still be selected.

4. In most cases, a radiogroup contains at least two radiobutton

5. In most cases, radiobutton in a radiogroup will be selected by default. We recommend that you place it in the starting position of the radiogroup.

Case study: http://my.oschina.net/amigos/blog/59261

Related Article

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.