1. <tfoot id='EeFTP'></tfoot>

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

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

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

        “"的作用是什么isViewFromObject(视图视图,对象对象)"在 FragmentStat

        时间:2023-10-04
        <legend id='JO8Qz'><style id='JO8Qz'><dir id='JO8Qz'><q id='JO8Qz'></q></dir></style></legend>

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

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

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

                  本文介绍了“"的作用是什么isViewFromObject(视图视图,对象对象)"在 FragmentStatePagerAdapter 中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 View Pager 中使用 FragmentStatePagerAdapter.如果 isViewFromObject (View view, Object object) 返回 false,则返回的 Fragment 不会显示在屏幕上.这是为什么?
                  开发者文档说 Determines 页面视图是否与由 instantiateItem(ViewGroup, int) 返回的特定键对象相关联.PagerAdapter 需要此方法才能正常运行. 但我不清楚这个定义.

                  I am using a FragmentStatePagerAdapter with my View Pager. The Fragment returned is not displayed on the screen if isViewFromObject (View view, Object object) returns false. Why is that?
                  The developer doc says Determines whether a page View is associated with a specific key object as returned by instantiateItem(ViewGroup, int). This method is required for a PagerAdapter to function properly. But I am not clear with this definition.

                  推荐答案

                  方法 instantiateItem(ViewGroup, int) 返回特定视图的 Object.PagerAdapter 实现在 viewpager 更改页面时将此 Object 视为 key 值.

                  The method instantiateItem(ViewGroup, int) returns Object for a particular view. PagerAdapter implementation is considering this Object as a key value when viewpager changes a page.

                  因此,如果我们从 instantiateItem(ViewGroup, int) 返回视图本身,那么该页面的 key 将成为视图本身.我们可以检查 return view == object; from isViewFromObject (View view, Object object) 总是返回 true 并且我们的页面将显示:

                  So, if we return the view itself from instantiateItem(ViewGroup, int), then our key for that page becomes the view itself. We can check return view == object; from isViewFromObject (View view, Object object) which will always return true and our pages will display :

                  public boolean isViewFromObject(View view, Object object) {
                      return view == object;
                  }
                  

                  来自 https://stackoverflow.com/a/16772250/1994950 帖子的更多见解:

                  Some more insights from post https://stackoverflow.com/a/16772250/1994950 :

                  当您滑动时,ViewPager 从数组中获取视图位置或实例化它,并使用适配器方法 public boolean isViewFromObject(视图视图,对象对象).在ViewPager 上向用户显示等于object 的视图.如果没有视图,则显示空白屏幕.

                  When you slide, the ViewPager gets view position from an array or instantiates it and compare this view with children of ViewPager with adapters method public boolean isViewFromObject(View view, Object object). The view which equals to object is displayed to the user on ViewPager. If there is no view then the blank screen is displayed.

                  这里是 ViewPager 方法,用于将视图与对象进行比较:

                  Here is ViewPager method where the view is compared to object:

                  ItemInfo infoForChild(View child) {
                      for (int i=0; i<mItems.size(); i++) {
                          ItemInfo ii = mItems.get(i);
                          if (mAdapter.isViewFromObject(child, ii.object)) {
                              return ii;
                          }
                      }
                      return null;
                  }
                  

                  这篇关于“"的作用是什么isViewFromObject(视图视图,对象对象)"在 FragmentStatePagerAdapter 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何正确使用 ViewPager 的片段? 下一篇:具有两个选项卡的 ViewPager 在滑动和单击时会导致 IndexOutOfBoundsException

                  相关文章

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

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

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