我正在做一個測驗應用程序我有一個收音機組與4個單選按鈕,我有一個下一個按鈕。如何取消選中組中的單選按鈕?
在顯示時第一個問題並沒有問題,當用戶給下一個時,收音機組應該取消選中。如何實現這一點?
當用戶選擇它應該驗證答案是正確的或不正確的選項。我已經將正確答案存儲在一個數組中。當用戶切換選項時,它會在切換按鈕中顯示錯誤。如何實現這一點?
btn_practicerg.setOnCheckedChangeListener(new OnCheckedChangeListener(){ @Override public void onCheckedChanged(RadioGroup group, int checkedId) { RadioButton radioButton = (RadioButton)group. findViewById(checkedId); String temp = radioButton.getText().toString(); switch(btn_practicerg.getCheckedRadioButtonId()){ case R.id.RB1: if (btn_practice1.isChecked()){ btn_practice2.setChecked(false); btn_practice3.setChecked(false); btn_practice4.setChecked(false); } break; case R.id.RB2: if (btn_practice2.isChecked()){ btn_practice1.setChecked(false); btn_practice3.setChecked(false); btn_practice4.setChecked(false); } break; case R.id.RB3: if (btn_practice3.isChecked()){ btn_practice1.setChecked(false); btn_practice2.setChecked(false); btn_practice4.setChecked(false); } break; case R.id.RB4: if (btn_practice4.isChecked()){ btn_practice1.setChecked(false); btn_practice2.setChecked(false); btn_practice3.setChecked(false); } break; } crrtans=new ArrayList<String>(new ArrayList<String>(crrtans)); if (temp.equals(crrtans.get(l))){ TextView txtRadio = (TextView) findViewById(R.id.rdtxt); txtRadio.setText("" + radioButton.getText() + " IS CORRECT"); txtRadio.setTextColor(Color.parseColor("#008000")); }else{ TextView txtRadio = (TextView) findViewById(R.id.rdtxt); txtRadio.setText("" + radioButton.getText() + "is INCORRECT"); txtRadio.setTextColor(Color.parseColor("#FF0000")); } } }); Button nextBtn = (Button) findViewById(R.id.nxt_btn); nextBtn.setOnClickListener(new Button.OnClickListener(){ public void onClick(View v){ if (j == ques1.size() -1) { showAlert1(); } else{ ++j; ++num; TextView txtque = (TextView) findViewById(R.id.que_txt); txtque.setText("Q" + num +ques1.get(j)); } });
檢查我的答案.... – 2013-02-13 08:10:30