I am using a FragmentPagerAdapter with fragments. My problem is that when I call setCurrentItem, the OnCreateView method of the fragment that loads is called twice. It is important to note, however, that the fragment is not recreated, it simply resumes. I am desperately looking for a solution that calls OnCreateView only once.
It is not called twice. What you are experiencing is the default ViewPager , which always caches at least one of its pages ( Fragment ), depending on the value of setOffscreenPageLimit(int limit) . Therefore, onCreateView is called once for each instance returned by getItem
source share