Code example for RadioButton

Methods: getTextsetEnabledsetText, isChecked, setChecked

0
		} 
	} 
	 
	private void nextOnClick()	{		 
 
			if(rbn1.isChecked()) {
				rbnString = (String) rbn1.getText();
			   	selectedAnswers[count_question] = rbnString;
			} 
			if(rbn2.isChecked()) {
				rbnString = (String) rbn2.getText();
			   	selectedAnswers[count_question] = rbnString;
			} 
			if(rbn3.isChecked()) {
				rbnString = (String) rbn3.getText();
			   	selectedAnswers[count_question] = rbnString;
			} 
			if(rbn4.isChecked()) {
				rbnString = (String) rbn4.getText();
			   	selectedAnswers[count_question] = rbnString;
			} 
		    if(rbnString.equals(corrString)) {
		    	++count_correct;
		    } 
			if(c.isLast()){
				button4.setVisibility(View.VISIBLE);
				button1.setEnabled(true);
				button2.setEnabled(false);
				button3.setEnabled(false);
				button4.setEnabled(true);
			} 
			else { 
				++count_question;
				c.moveToNext();
				setNewQuestion(); 
				setValues(); 
			} 
		} 
	 
	 
	private void confirmOnClick()	{ 
		if(button3.getText().toString() == "Confirm") {
 
			button1.setEnabled(false);
			button2.setEnabled(true);
			button3.setText("Cancel");
		} 
		else 
			setNewQuestion(); 
	} 
	 
	// Submit the result and open the "View Answers" intent. 
	private void submitOnClick()	{ 
		Intent myIntent = new Intent();
		myIntent.setClass(this, Result.class);
		Bundle bundle = new Bundle();
		bundle.putInt("key", count_correct);
		bundle.putStringArray("selected_answer", selectedAnswers);
		myIntent.putExtras(bundle);
		startActivityForResult(myIntent,0);
	} 
	 
	// Set the values of the display elements 
	private void setValues()	{ 
		qno.setText(""+count_question);
		question.setText(c.getString(c.getColumnIndex("Question")).toString());
		rbn1.setText(c.getString(c.getColumnIndex("Choice1")).toString());
		rbn2.setText(c.getString(c.getColumnIndex("Choice2")).toString());
		rbn3.setText(c.getString(c.getColumnIndex("Choice3")).toString());
		rbn4.setText(c.getString(c.getColumnIndex("Choice4")).toString());
		corrString =(c.getString(c.getColumnIndex("Correct")).toString());
	} 
	 
	// Set a new Question 
	private void setNewQuestion()	{ 
		 
		rbn1.setEnabled(true);
		rbn1.setChecked(false);
		 
		rbn2.setEnabled(true);
		rbn2.setChecked(false);
		 
		rbn3.setEnabled(true);