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