我想做的只是调用我的Fragment类中的一个函数。但是我似乎找不到一种方法来访问我的ViewPager中的片段实例。
我的活动xml:
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" />
没有 id
,所以我无法调用 findFragmentById()
(可以吗?)
另外,我不知道要给 findFragmentByTag()
什么参数,它总是返回 null :/