QMUI double-layer ViewPage nesting, the second layer of viewPage page does not display data after switching

Problem Description: 

ViewPager is nested in ViewPager and fills data with Fragment, but after switching the outer ViewPager, there is no way to load the data in the inner ViewPager. For example: when I switch to the home page and then return to the home page, the data in it cannot be loaded.



Solution: 
adapter = new TabAdapter(getFragmentManager(), consName, mConsFragments); 
adapter = new TabAdapter(getChildFragmentManager(), consName, mConsFragments); 
just change getFragmentManager() to getChildFragmentManager().

Analysis: 
getFragmentManager is to the Manager of the fragment contained in the activity, and if it is a fragment nested fragment, then you need to use getChildFragmentManager(). 
getFragmentManager() is the fragment management of the parent container of the fragment, and 
getChildFragmentManager() is the fragment management of the child container in the fragment.

Reprinted from   the CSDN blog that just recognized the big brother


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325764175&siteId=291194637