我在广播组中创建了 2 个组,其中一个问你踢足球好吗?另一个关于篮球的。如果它们很好,我给了 3 分,我想计算我的程序中的总分,但我不能。我需要帮助
private void addListenerOnButton() {
final RadioGroup football = (RadioGroup) findViewById(R.id.radioGroup1);
Button calc = (Button) findViewById(R.id.diabetriskbutton1);
final RadioGroup basketball = (RadioGroup) findViewById(R.id.radioGroup2);
calc.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
int IDfootball = football.getCheckedRadioButtonId();
RadioButton football = (RadioButton) findViewById(IDfootball);
if (IDfootball == R.id.item1yes) {
int scorefootball = 3;
} else if (IDfootball == R.id.item1no) {
int scorefootball = 2;
}
int IDbasketball = basketball.getCheckedRadioButtonId();
RadioButton basketball = (RadioButton) findViewById(IDbasketball);
if (IDbasketball == R.id.item1yes) {
int scorebasketball = 3;
} else if (IDbasketball == R.id.item1no) {
int scorebasketball = 2;
}
scoretotal = scorefootball + scorebasketball ;
}
});
}`