Now I have an adapter class that extends the PagerAdapter. Inside, I have an InstantiateItem () method.
Here I create some buttons on the view:
@Override public Object instantiateItem(ViewGroup parent, final int position) { final int delPosition = position;
Here's the onClick action for buttosn:
//onClickListener method that returns an interface private View.OnClickListener createClickListener(final int value) { return new View.OnClickListener() { @Override public void onClick(View view) { buttonValue = value; ToggleButton clickedButton = (ToggleButton) view; RadioGroup radioGroup= (RadioGroup) clickedButton.getParent(); for (int i = 0; i < radioGroup.getChildCount(); ++i) { View nextChild = radioGroup.getChildAt(i); if (!(nextChild instanceof ToggleButton)) { continue; } if (nextChild.getId() != clickedButton.getId() || !clickedButton.isChecked()) { ToggleButton tb2 = (ToggleButton) nextChild; tb2.setChecked(false); } } } }; }
I want to save the state of the button by clicking (right now, like a radio book, and when the user clicks on it, the state of the button is pressed until they switch to another button), and buttonValue between the views in the viewpager.
Ultimately, I want to see at the end of my viewpager where I can list all the points for each view, also return the user to other views and still click on their button so that they can confirm this by swaying between the views.
I ran into two problems right now:
1) Only the last buttonValue is saved, not all the Values โโbuttons for all views. How can I achieve the preservation of all points in all submissions, and not just the last point in the last submission?
2) The transition from one view to another and vice versa, the state of the button is still pressed. However, if I move to the third view from the last point, pressing the button will no longer be valid. How can i fix this?