I solve problem by setting text view on view pager activity and setting on click on same class.I receive page number by function viewPager.getcurrentItem();(viewpager is object of class ViewPager).
Reloading fragment in view pager by radio button click
-
19-10-2022 - |
Question
I have view pager and fragments to show some question on it .I set option of questions as radio buttons. I need to set answer so that it will be only shown when i click one of the option .I have on click function in view pager and answer on fragment class .But how i reload the current fragment view on clicking radiobutton.(when i try to reload the view automaticaly goes back to first view ).?
Solution 2
OTHER TIPS
Follow this steps:
You have to extend from FragmentStatePagerAdapter instead FragmentPagerAdapter 'cause the last one never change contained fragments. Then in extended adapter add one more method:
@Override
public int getItemPosition(Object object) {
return POSITION_NONE;
}
In you main activity class, that contain ViewPager
create method:
public YourExtendedApdaterClass getAdapter(){
return instanceOfAdapter;
}
After that in you fragment call this wherever you want to update fragments:
((YourActivityClass)getActivity()).getAdapter().notifyDataSetChanged();