How To Do The Next Button Action?
Solution 1:
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:
publicvoidsetValues(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.
Post a Comment for "How To Do The Next Button Action?"