<bdo id='KDAXF'></bdo><ul id='KDAXF'></ul>

      <legend id='KDAXF'><style id='KDAXF'><dir id='KDAXF'><q id='KDAXF'></q></dir></style></legend>
      <i id='KDAXF'><tr id='KDAXF'><dt id='KDAXF'><q id='KDAXF'><span id='KDAXF'><b id='KDAXF'><form id='KDAXF'><ins id='KDAXF'></ins><ul id='KDAXF'></ul><sub id='KDAXF'></sub></form><legend id='KDAXF'></legend><bdo id='KDAXF'><pre id='KDAXF'><center id='KDAXF'></center></pre></bdo></b><th id='KDAXF'></th></span></q></dt></tr></i><div id='KDAXF'><tfoot id='KDAXF'></tfoot><dl id='KDAXF'><fieldset id='KDAXF'></fieldset></dl></div>
      <tfoot id='KDAXF'></tfoot>
    1. <small id='KDAXF'></small><noframes id='KDAXF'>

      1. TabFragment 中的 ViewPager 未再次加载

        时间:2023-10-04
        <i id='y1XTp'><tr id='y1XTp'><dt id='y1XTp'><q id='y1XTp'><span id='y1XTp'><b id='y1XTp'><form id='y1XTp'><ins id='y1XTp'></ins><ul id='y1XTp'></ul><sub id='y1XTp'></sub></form><legend id='y1XTp'></legend><bdo id='y1XTp'><pre id='y1XTp'><center id='y1XTp'></center></pre></bdo></b><th id='y1XTp'></th></span></q></dt></tr></i><div id='y1XTp'><tfoot id='y1XTp'></tfoot><dl id='y1XTp'><fieldset id='y1XTp'></fieldset></dl></div>
          <tbody id='y1XTp'></tbody>

          1. <small id='y1XTp'></small><noframes id='y1XTp'>

              <bdo id='y1XTp'></bdo><ul id='y1XTp'></ul>
                  <legend id='y1XTp'><style id='y1XTp'><dir id='y1XTp'><q id='y1XTp'></q></dir></style></legend>
                • <tfoot id='y1XTp'></tfoot>
                  本文介绍了TabFragment 中的 ViewPager 未再次加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试制作一个在属于 TabHost 的片段中具有 ViewPager 的应用.一切正常.我有我的标签栏,我可以切换标签.当我使用 ViewPager 切换到选项卡时,一切都正确显示.

                  I'm trying to make an app that has a ViewPager in a Fragment that is part of a TabHost. Everything works out fine. I have my tabbar, I can switch tabs. When I switch to the tab with the ViewPager, all is shown correctly.

                  但是,一旦我离开此标签并使用 ViewPager 并返回此标签,我的内容就不会显示.如果我滚动到一边两次,我确实会看到我的下一张图片,如果我返回两次,我还会看到图片已加载(可能是 offscreenloaded).

                  However, as soon as I leave this tab with the ViewPager and return this tab, my content is not shown. If I scroll to the side twice I do see my next image and if I go back two times I also see the images are loaded (probably the offscreenloaded).

                  看到我的 TabFragment 正在重新实例化,但 ViewPager 中的片段却没有.

                  See that my TabFragment is being reinstantiated when I return to it but the fragments in the ViewPager aren't.

                  @Override
                  public void onActivityCreated(Bundle savedInstanceState) {
                  
                      mProjectText = (TextView) getView().findViewById(R.id.projectText);
                      mProjectText.setText(mActiveProject.getInspirationText());
                  
                      mAdapter = new AlbumAdapter(getFragmentManager(), mActiveProject.getInspiration());
                  
                      mPager = (ViewPager)getView().findViewById(R.id.pager);
                      mPager.setAdapter(mAdapter);
                  
                      super.onActivityCreated(savedInstanceState);
                  }
                  
                  public class AlbumAdapter extends FragmentStatePagerAdapter {
                  
                  private ArrayList<ProjectContent> mItems;
                  
                  public AlbumAdapter(FragmentManager fm, ArrayList<ProjectContent> items) {
                      super(fm);
                      this.mItems = items;
                  }
                  
                  @Override
                  public Fragment getItem(int position) {
                      return AlbumContentFragment.newInstance(mItems.get(position));
                  }
                  
                  @Override
                  public int getCount() {
                      return mItems.size();
                  }
                  
                  @Override
                  public int getItemPosition(Object object) {
                      return POSITION_NONE;
                  }}
                  

                  推荐答案

                  我发现了问题.我花了两天时间,但嘿,它已经修好了.

                  I found the problem. It took me two days, but hey, it's fixed.

                  而不是使用

                  mAdapter = new AlbumAdapter(getFragmentManager(), mActiveProject.getInspiration());
                  

                  你应该使用

                  mAdapter = new AlbumAdapter(getChildFragmentManager(), mActiveProject.getInspiration());
                  

                  5 个字符就这么多.

                  这篇关于TabFragment 中的 ViewPager 未再次加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:具有两个选项卡的 ViewPager 在滑动和单击时会导致 IndexOutOfBoundsException 下一篇:如何仅在 PagerSlidingTabStrip 中单击其选项卡时加载片段数据

                  相关文章

                  <legend id='a5PqP'><style id='a5PqP'><dir id='a5PqP'><q id='a5PqP'></q></dir></style></legend>

                  <i id='a5PqP'><tr id='a5PqP'><dt id='a5PqP'><q id='a5PqP'><span id='a5PqP'><b id='a5PqP'><form id='a5PqP'><ins id='a5PqP'></ins><ul id='a5PqP'></ul><sub id='a5PqP'></sub></form><legend id='a5PqP'></legend><bdo id='a5PqP'><pre id='a5PqP'><center id='a5PqP'></center></pre></bdo></b><th id='a5PqP'></th></span></q></dt></tr></i><div id='a5PqP'><tfoot id='a5PqP'></tfoot><dl id='a5PqP'><fieldset id='a5PqP'></fieldset></dl></div>
                    <bdo id='a5PqP'></bdo><ul id='a5PqP'></ul>

                  <small id='a5PqP'></small><noframes id='a5PqP'>

                • <tfoot id='a5PqP'></tfoot>