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

      <tfoot id='yZ3SS'></tfoot>
        <bdo id='yZ3SS'></bdo><ul id='yZ3SS'></ul>

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

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

        如何使用带有底部导航和 viewpager 的 tablayout?

        时间:2023-10-03

        • <bdo id='F7Uz8'></bdo><ul id='F7Uz8'></ul>
          <tfoot id='F7Uz8'></tfoot>

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

                    <tbody id='F7Uz8'></tbody>

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

                • 本文介绍了如何使用带有底部导航和 viewpager 的 tablayout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了一个带有底部导航栏的活动.当我想切换到另一个片段时,我想要 tablayout.而tablayout可以控制viewpager.我可以把viewpager放到指定的fragment吗?

                  I created an activity with a bottom navigation bar. I want tablayout when I want to switch to another fragment. And tablayout can control viewpager. Can I put viewpager to the specified fragment?

                  我想要这样:

                  这是当前结果.我想把 viewpager 放在红框里.

                  This is the current result. I want to put viewpager in the red box.

                  推荐答案

                  试试这个来同步你的 BottomNavigationViewTabLayoutViewPager

                  Try this to sync your BottomNavigationView and TabLayout with ViewPager

                      myBottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
                          @Override
                          public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                  
                              int id = item.getItemId();
                  
                              if (id == R.id.action_one) {
                                  myViewPager.setCurrentItem(0);
                              }else if (id == R.id.action_two) {
                                  myViewPager.setCurrentItem(1);
                              }else if (id == R.id.action_three) {
                                  myViewPager.setCurrentItem(2);
                              }else if (id == R.id.action_four) {
                                  myViewPager.setCurrentItem(3);
                              }
                              return false;
                          }
                      });
                  
                  
                      myViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
                          @Override
                          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                              if (position == 0) {
                                  myBottomNavigationView.setSelectedItemId(R.id.action_one);
                              }else if (position == 1) {
                                  myBottomNavigationView.setSelectedItemId(R.id.action_two);
                              }else if (position == 2) {
                                  myBottomNavigationView.setSelectedItemId(R.id.action_three);
                              }else if (position == 3) {
                                  myBottomNavigationView.setSelectedItemId(R.id.action_four);
                              }
                          }
                  
                          @Override
                          public void onPageSelected(int position) {
                  
                          }
                  
                          @Override
                          public void onPageScrollStateChanged(int state) {
                  
                          }
                      });
                  

                  这篇关于如何使用带有底部导航和 viewpager 的 tablayout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:临时/动态禁用 Viewpager 中的单个页面 下一篇:ViewPager 中的片段在其 RecyclerView 旋转时未显示任何内容

                  相关文章

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

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

                    <tfoot id='kaIUC'></tfoot>

                    1. <legend id='kaIUC'><style id='kaIUC'><dir id='kaIUC'><q id='kaIUC'></q></dir></style></legend>

                      • <bdo id='kaIUC'></bdo><ul id='kaIUC'></ul>