문제

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 ).?

도움이 되었습니까?

해결책 2

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).

다른 팁

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top