How to do the next button action?

前端 未结 1 1597
感动是毒
感动是毒 2021-01-26 03:52

I\'m facing a problem in Next button while displaying the next question.

In my first time set text I\'m getting the correct question and matched four option answers. Wha

相关标签:
1条回答
  • 2021-01-26 04:27

    I assume, you are trying to manage question and its options on next/previous buttons click.

    I achieved in my one of app same as you want:

    Step1@ take one int count=0 define globally.

    Step2@ when activity is called initially first question will be display with options.

    setValues(count); // here I am setting question and options to textview inside setValues named method.

    Step3@ onClick of NextButton check condition something like below:

    if (count == question.size() - 1) {
        finish();
        break;
    } 
    
    else {
    count++;
    setValues(count);
       }
    

    Step4@ onClick of PreviousButton check condition something like below:

    if (count <= 0) {
    Toast.makeText(OnPurposeUPSQuesAcitivty.this, "First Record",Toast.LENGTH_SHORT).show();
    break;
    } else {
    count--;
    setValues(count);
    }
    

    Your setValue method something look like below:

    public void setValues( int j) {
    txtque.setText(ques1.get(j));            
    
    btn_practice1.setText(answ1.get(j);
    btn_practice2.setText(answ1.get(j);
    btn_practice3.setText(answ1.get(j);
    btn_practice4.setText(answ1.get(j);
    }
    

    ...........

    Last Point@ After review your code, I don't came across that how you are setting values to options.

    this

    btn_practice1.setText(answ1.get((k*4)+0));

    Will you explain above line of code, will update my answer, else you can use my solution as I mention above steps wise.

    0 讨论(0)
提交回复
热议问题