I have a ViewPager. My FragmentPageAdapter returns the position of the Viewpager in the getItem () method. But after turning the screen, the method does not return a value. What for? If I understand correctly, each time you rotate the screen, OnCreateView () is called, but why doesn’t it return a value anymore? Can someone point out how to solve this? thank you
Edit: My FragmentPageAdapter:
public Fragment getItem(int position) { return Fragment_results.newInstance(position); }
My snippet:
public static Fragment_results newInstance(int i) { Fragment_results fragment = new Fragment_results(); fragment.mContent = i +""; return fragment; } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.layout_result, null); ((TextView) view.findViewById(R.id.text)).setText(mContent);
Ahmad source share