我正在尝试设置一个测验,其中每个答案都会在总分中增加一定数量的分数。目前,我关心单选按钮。我已经建立了一个单选组,我希望选择任何单选按钮来添加到总分中。这只是我的程序的一部分,只是要注意。
当我按下 xml 布局文件底部的按钮时,我希望将与单选按钮关联的分数添加到总分中。你明白吗?
这是实际 xml 布局文件的类文件:
Public class QuestionOne extends Results {
RadioButton answer1, answer2, answer3;
Button oneNext;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.one);
RadioButton answer1 = (RadioButton) findViewById(R.id.oneradio1);
RadioButton answer2 = (RadioButton) findViewById(R.id.oneradio2);
RadioButton answer3 = (RadioButton) findViewById(R.id.oneradio3);
Button oneNext = (Button) findViewById(R.id.onenext);
}
}
它扩展了 Results 类,我这样做是为了继承分数整数。这是分数等级:
public class Results extends Activity {
private int score;
public int getScore() {
return score;
}
public Results(int score) {
this.score = score;
}
}
我从谷歌上得到了这个结构,我敢肯定它的有效性值得怀疑,但我认为我有基本的想法。谁能帮我吗?