I have InnerFragment containing RecyclerView, inside MainFragment which is added to ViewPager. When MainFragment gets created while swiping OnResume is called multiple times
- 1st time : OnResume called once in MainFragment and Once in InnerFragment
- 2n time : OnResume called once in MainFragment and Twice in InnerFragment
- 3rd time : OnResume called once in MainFragment and Thrice in InnerFragment
Adding MainFragment in ViewPager
//Assigning Adapter in ViewPager
mViewPager.setAdapter(new MyAdapter(getFragmentManager()));
//getItem inside MyAdaper
public Fragment getItem(int position){
return MainFragment.newInstance(position);
}
Adding InnerFragment in MainFragment
getChildFragmentManager().beginTransaction().add(R.id.framelayoutID, InnerFragment.newInstance()).commit();