Radiogroup radiobutton, checkbox, menu

Source: Internet
Author: User

 

Multiple radiobutton instances in the rdiogroup.

// set the listener for the radiogroup. The Listener here is different from the listener for the button control.
gendergroup. setoncheckedchangelistener (New radiogroup. oncheckedchangelistener () {
@ override
Public void oncheckedchanged (radiogroup group, int checkedid) {
// todo auto-generated method stub
If (femalebutton. GETID () = checkedid) {
system. out. println ("famale");
toast. maketext (radiotest. this, "famle", toast. length_short ). show ();
}< br> else if (malebutton. GETID () = checkedid)
{< br> system. out. println ("male");
}< BR >});

Checkbox does not have a group concept, so every one must listen.
// Add a listener for the multiple-choice button
Product_box. setoncheckedchangelistener (New compoundbutton. oncheckedchangelistener (){
@ Override
Public void oncheckedchanged (compoundbutton buttonview, Boolean ischecked ){
// Todo auto-generated method stub
If (ischecked)
{
System. Out. println ("swim is checked ");
}
Else
{
System. Out. println ("swim is unchecked ");
}
}
});

Public Boolean oncreateoptionsmenu (menu ){

Menu. add (0, 1, R. string. exit); // The first element is the group ID, the second element is the current menu ID, the third element is the sorting, and the fourth element is the display content.

Menu. Add (0, 2, R. String. About );

Return super. oncreateoptionsmenu (menu );}

 

Public Boolean onoptionsitemselected (menuitem item ){

If (item. getitemid () = 1)

Finish ();}

Return super. onoptionitemselected (item );

}

 

Integer. parseint () to integer

Settext (result + ""); where result is an integer, but there is a space next to it as a string, both sides will be converted into a string

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.