Home > Mobile >  How to do with radiobutton summation.
How to do with radiobutton summation.

Time:09-26

Layout simulation are as follows: Radiogroup
Radiobutton1
Radiobutton2
Radiobutton3
Radiogroup
Radiobutton4
Radiobutton5
Radiobutton6

The Button

Give radiobutton1 assignment 1
Give radiobutton2 assignment for 2
Give radiobutton3 assignment for 3
Give radiobutton4 assignment is 4
Give radiobutton5 assignment for 5
Give radiobutton6 assignment is 6

And then I click on the button, can be summed up, such as I ordered radiobutton1 and radiobutton5
The sum of the value of 6

CodePudding user response:

Look at the radiogroup specific usage

Private int btn_num1;
Private int btn_num2;
Radiogroup1. SetOnCheckedChangeListener (new RadioGroup. OnCheckedChangeListener () {
@ Override
Public void onCheckedChanged (RadioGroup group, int checkedId) {
The switch (checkedId) {
Case R.i d.r adiobutton1:
Btn_num1=Integer. ParseInt (" 1 ")
break;
Case R.i d.r adiobutton2:
Btn_num1=Integer. ParseInt (" 2 ")
break;
.

}
}

});
The above radiogroup2
Button click sum not to mention

CodePudding user response:

reference 1/f, no fucker said reply:
to have a look at specific usage radiogroup

Private int btn_num1;
Private int btn_num2;
Radiogroup1. SetOnCheckedChangeListener (new RadioGroup. OnCheckedChangeListener () {
@ Override
Public void onCheckedChanged (RadioGroup group, int checkedId) {
The switch (checkedId) {
Case R.i d.r adiobutton1:
Btn_num1=Integer. ParseInt (" 1 ")
break;
Case R.i d.r adiobutton2:
Btn_num1=Integer. ParseInt (" 2 ")
break;
.

}
}

});
The above radiogroup2
Button click sum not to mention the right

After the meal I try,,,,,,,,,,
  • Related