Is it possible to access the current Fragment being viewed by a ViewPager?(是否可以访问 ViewPager 正在查看的当前片段?)
问题描述
我有一个带有 ViewPager
和三个 Fragment
的应用.我试图弄清楚如何查看当前的 Fragment
以便我可以了解它的论点.
I have an app with a ViewPager
and three Fragment
s. I'm trying to figure out how to get the current Fragment
being viewed so I can get at its arguments.
我有一个 OnPageChangeListener
抓取当前页面索引,但是
I have an OnPageChangeListener
grabbing the current page index, but
返回一个视图
.这个View
和当前的Fragment
是什么关系?
returns a View
. What's the relationship between this View
and the current Fragment
?
推荐答案
终于找到一个对我有用的答案.基本上,您可以使用标签android:switcher:"+R.id.viewpager+:0"访问viewPager 页面的片段.
I finally found an answer that worked for me. Basically, you can access the fragment for a viewPager page by using the tag "android:switcher:"+R.id.viewpager+":0".
这篇关于是否可以访问 ViewPager 正在查看的当前片段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!