【问题标题】:Disappear SmartTabLayout pageViewer content消失 SmartTabLayout pageViewer 内容
【发布时间】:2015-11-21 01:02:27
【问题描述】:

我正在尝试从这里https://github.com/ogaclejapan/SmartTabLayout 使用 SmartTabLayout,并且我有一个抽屉。当我单击抽屉上的项目时,我将片段替换为 smarttablayout 片段。第一次没问题,smarttablayout 有带有内容的标签,但是当我在同一个项目上单击抽屉时,标签的内容就会消失,并且要显示它们,我必须滚动到最后,然后向后滚动以显示它们。我不知道为什么。

【问题讨论】:

    标签: java android android-viewpager


    【解决方案1】:

    注意:如果在 ViewPager 中使用片段,必须使用 Fragment#getChildFragmentManager()。

    https://github.com/ogaclejapan/SmartTabLayout#pageradapter-for-fragment-based-page

    FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(
                getChildFragmentManager(), FragmentPagerItems.with(this.getA())
                .add(R.string.item_pager_title_products, ProductListFragment.class)
                .add(R.string.item_pager_title_shops, ShopListFragment.class)
                .create());
    

    仅供参考:有同样的问题,因为我没有阅读手册...在这里找到原始答案https://stackoverflow.com/a/25525714/1257369

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-23
      • 1970-01-01
      • 2015-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多