I am creating a basic quiz app, where the user is shown one question after another.
In order to get to the next question, the user has to click on a button.
Now, I only want this button, which gets the user to the next question, to be visible after he chose one of the possible answers (RadioButtons). It does not matter which of the RadioButtons in the RadioGroup has been selected, it is only important that he has clicked on an answer! I found a way to do this, but I am unsure this is the best way to do this:
> public void startQuiz(View view) {
> setContentView(R.layout.question_1);
> RadioGroup rg1 = (RadioGroup) findViewById(R.id.r_group_1);
> rg1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
> @Override
> public void onCheckedChanged(RadioGroup group, int checkedId) {
> switch (checkedId) {
> case R.id.radio_button_a_q1:
> View nb1 = findViewById(R.id.nb1);
> nb1.setVisibility(View.VISIBLE);
> break;
> case R.id.radio_button_b_q1:
> nb1 = findViewById(R.id.nb1);
> nb1.setVisibility(View.VISIBLE);
> break;
> case R.id.radio_button_c_q1:
> nb1 = findViewById(R.id.nb1);
> nb1.setVisibility(View.VISIBLE);
> break;
> }
> }
> }
> ); }
Thank you so so much in advance! :-)