Problems that may occur when multiple viewpagers exist.
Due to the convenience of Fragment, many people are now using Fragment in large quantities. If you encounter problems during use today, record them and share them.
FragmentActivity is used when Fragment is used, especially when ViewPager is used. Because FramgmentManager is required,
This time, ViewPager is used in both fragment. In fact, I did not consider it at the beginning. Then the FramgmentManager of the FragmentActivity is used for processing. However, when the first page is opened, the second page is displayed. The content on the second page is empty. view the log, the onCreatView method of the subview of ViewPager on the second page is not called ..
Baidu found that the tag in the instantiateItem of PagerAdapter was used to query Fragment from FramgmentManager. If the tag is found, the previous one will be used directly instead of being created again,
PagerAdapter tags are generated based on your pagerID and index.
What is it about? It indicates that the first page has a Fragment with the same tag as the second page. That is, two fragment instances have the same parent id and index.
The same pagerID is used.
Then I think of the layout file that was directly copied at that time, so the id is the same and the id is changed to solve the problem.
The problem lies in two key points:
1. The same FramgmentManager instance is used.
2. The ViewPager id is the same.
Therefore, when using this container type control, try to make the id different. Otherwise, a similar problem may occur.
Reference: http://www.trinea.cn/android/android-source-code-analysis/multi-viewpager-to-fragment-not-init/