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

<tfoot id='dXHGP'></tfoot>
    1. <small id='dXHGP'></small><noframes id='dXHGP'>

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

        如何在片段内实现viewpager?

        时间:2023-10-04

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

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

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

                  本文介绍了如何在片段内实现viewpager?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我一直在寻找并且很难找到一个明确的例子?我正在尝试了解如何在我的 mainActivity 中作为抽屉项打开的片段中创建一个 viewpager...

                  这是我的尝试,但我认为我做错了什么,无论是我错误地包含它还是将它放在错误的位置......

                  public class RandomFragment extends android.app.Fragment {@覆盖public View onCreateView(LayoutInflater inflater, ViewGroup 容器,捆绑保存的InstanceState){查看 rootView = inflater.inflate(R.layout.fragment_random, container, false);返回根视图;}@覆盖public void onViewCreated(View view, Bundle savedInstanceState) {super.onViewCreated(view, savedInstanceState);ViewPager mViewPager = (ViewPager) view.findViewById(R.id.random_pager);mViewPager.setAdapter(new MyAdapter(getChildFragmentManager()));}公共静态类 MyAdapter 扩展 FragmentPagerAdapter {公共 MyAdapter(FragmentManager fm) {超级(调频);}@覆盖公共 int getCount() {返回 4;}@覆盖公共片段getItem(int位置){捆绑参数 = 新捆绑();args.putInt(TextViewFragment.POSITION_KEY, 位置);返回 TextViewFragment.newInstance(args);}}

                  解决方案

                  我用这个希望对你也有帮助:https://github.com/thecodepath/android_guides/wiki/ViewPager-with-FragmentPagerAdapter

                  所以你可以使用这个:https://github.com/astuetz/PagerSlidingTabStripp>

                  I have been looking and having a hard time finding a clear cut example? I am trying to understand how to create a viewpager within a fragment that is open as a drawer item from my mainActivity...

                  This is my attempt but I think I am doing something wrong whether it be that I am including it incorrectly or have it in the wrong spot...

                  public class RandomFragment extends android.app.Fragment {
                      @Override
                      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                               Bundle savedInstanceState) {
                  
                          View rootView = inflater.inflate(R.layout.fragment_random, container, false);
                  
                          return rootView;
                      }
                      @Override
                      public void onViewCreated(View view, Bundle savedInstanceState) {
                          super.onViewCreated(view, savedInstanceState);
                  
                          ViewPager mViewPager = (ViewPager) view.findViewById(R.id.random_pager);
                          mViewPager.setAdapter(new MyAdapter(getChildFragmentManager()));
                      }
                  
                      public static class MyAdapter extends FragmentPagerAdapter {
                  
                          public MyAdapter(FragmentManager fm) {
                              super(fm);
                          }
                  
                          @Override
                          public int getCount() {
                              return 4;
                          }
                  
                          @Override
                          public Fragment getItem(int position) {
                              Bundle args = new Bundle();
                              args.putInt(TextViewFragment.POSITION_KEY, position);
                              return TextViewFragment.newInstance(args);
                          }
                  }
                  

                  解决方案

                  I use this one hope it help you too : https://github.com/thecodepath/android_guides/wiki/ViewPager-with-FragmentPagerAdapter

                  So you can use this one: https://github.com/astuetz/PagerSlidingTabStrip

                  这篇关于如何在片段内实现viewpager?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将多个 ViewPagers 放入一个 ScrollView? 下一篇:ViewPager:java.lang.IllegalArgumentException:pointerIndex 超出

                  相关文章

                    <bdo id='3rmHF'></bdo><ul id='3rmHF'></ul>
                • <tfoot id='3rmHF'></tfoot>
                  <legend id='3rmHF'><style id='3rmHF'><dir id='3rmHF'><q id='3rmHF'></q></dir></style></legend>

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