我在保存单选按钮并再次检查时遇到问题..
我有一个单选组有四个单选按钮。对于每组中的第一次尝试单选按钮。当用户单击任何单选按钮并在用户从那里回来时转到下一个时,在这些单选按钮/单选按钮上所做的选择就消失了。
如何保存/恢复单选按钮选择状态?
我的代码..
private void LoadQuestions() {
ques1.add("whats the name?");
ques1.add("whats place?");
ques1.add("whats the favourite?");
ques1.add("whats the game?");
ques1.add("whats the time?");
answ1.add("A");answ1.add("B");answ1.add("C");answ1.add("D");
answ1.add("MDU");answ1.add("MS");answ1.add("CHE");answ1.add("POND");
answ1.add("1");answ1.add("2");answ1.add("3");answ1.add("4");
answ1.add("VB");answ1.add("TENN");answ1.add("HOC");answ1.add("CRI");
answ1.add("11");answ1.add("12");answ1.add("13");answ1.add("14");
quetxt = (TextView) findViewById(R.id.que_txt);
quetxt.setText("Q" + num + ")" + ques1.get(i));
btn_practice1.setText(answ1.get(0));
btn_practice2.setText(answ1.get(1));
btn_practice3.setText(answ1.get(2));
btn_practice4.setText(answ1.get(3));
Button nextBtn = (Button) findViewById(R.id.nxt_btn);
nextBtn.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
if (i == ques1.size() -1) {
showAlert();
}else{
++i;
++num;
TextView quetxt = (TextView) findViewById(R.id.que_txt);
quetxt.setText("Q" + num + ")" +ques1.get(i));
++k;
btn_practice1.setText(answ1.get((k*4)+0));
btn_practice2.setText(answ1.get((k*4)+1));
btn_practice3.setText(answ1.get((k*4)+2));
btn_practice4.setText(answ1.get((k*4)+3));
btn_practicerg.clearCheck();
}
}
private void showAlert() {
// TODO Auto-generated method stub
}
});
Button previousbtn1 = (Button) findViewById(R.id.accbtn);
previousbtn1.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
--i;
--num;
TextView quetxt = (TextView) findViewById(R.id.que_txt);
quetxt.setText("Q" + num + ")" + ques1.get(i));
--k;
btn_practice1.setText(answ1.get((k*4)+0));
btn_practice2.setText(answ1.get((k*4)+1));
btn_practice3.setText(answ1.get((k*4)+2));
btn_practice4.setText(answ1.get((k*4)+3));
}
});
}