[Android] radiobutton

Source: Internet
Author: User
1. The webview loading function was recently implemented. However, if the Option Button is placed in the webview, the response is very slow when you click it. Therefore, the native radiobutton option is used, and the question and answer are placed in webview. However, the number of options is unknown, so you need to add a button dynamically. A radiogroup stores a number of radio (these are data obtained from the database ), then, the code for dynamically adding buttons is as follows: ------------------ 4 5 private linearlayout layout; // layout. You can obtain 6 private radiogroup in the XML layout; // click the button group 7 8 Public void oncreate (bundle savedinstancestate) {9 super. oncreate (savedinstancestate); 10 11 layout = new linearlayout (this); // instantiate the layout object 12 13 group = new radiogroup (this ); // instantiate single-choice button group 14 15 // Add single-choice button 16 for (INT I = 0; I <5; I ++) {17 radiobutton radio = new radiobutton (this ); 18 radio. settext ("radio" + I); 19 group. addview (radio); 20} 21 22 // Add the radio button group to the layout 23 layout. addview (Group); 24 25 this. setcontentview (layout); 26}

 

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.