我正在回答问题和答案String[]
。TextView
有问题并RadioButton
有相应的答案。如果Start Button
单击 ,第一组问题和答案将显示在 中Linear Layout1
。如果Next Button
单击LinearLayout1
被替换为下一组带有答案的问题,如果再次Next Button
被单击,则必须替换下一组问题,反之亦然。帮我写代码Next Button
注意:仅LinearLayout 1
应在单击时更改Next Button
代码:
TextView tv;
RadioButton rb1, rb2;
Button bStart, bNext;
String question[] = { "Key Lime Pie is upcoming version",
"Android is Middleware", "Which is latest Android version?" };
String answerA[] = { "True", "False" };
String answerB[] = { "True", "False" };
String answerC[] = { "Android 4.2", "Android 5" };
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ques);
tv = (TextView) findViewById(R.id.textView111);
rb1 = (RadioButton) findViewById(R.id.radioButton1);
rb2 = (RadioButton) findViewById(R.id.radioButton2);
bStart = (Button) findViewById(R.id.startExam);
bNext = (Button) findViewById(R.id.bNext);
bStart.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
tv.setText(question[0]);
rb1.setText(answerA[0]);
rb2.setText(answerA[1]);
}
});
bNext.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
tv.setText(question[1]);
rb1.setText(answerB[0]);
rb2.setText(answerB[1]);
}
});
}