是否可以访问 ViewPager 正在查看的当前 Fragment? [英] Is it possible to access the current Fragment being viewed by a ViewPager?

查看:31
本文介绍了是否可以访问 ViewPager 正在查看的当前 Fragment?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 ViewPager 和三个 Fragment 的应用程序.我想弄清楚如何查看当前的 Fragment 以便我可以了解它的参数.

I have an app with a ViewPager and three Fragments. 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

ViewPager.getChildAt(int position);

返回一个 View.这个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 正在查看的当前 Fragment?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆