在 XML 中我有
<androidx.fragment.app.FragmentContainerView
android:id="@+id/identifications_map_view"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent" />
我想从视图中获取片段。这文档 https://developer.android.com/reference/androidx/fragment/app/FragmentContainerView#getFragment()建议使用
FragmentContainerView fcv = findViewById(R.id.identifications_map_view);
SupportMapFragment smf = fcv.getFragment()
但是 Android Studio 无法解析符号,并且如果我 CTRL+单击“FragmentContainerView”,当我使用 CTRL+F 搜索时,它不会显示 getFragment()。
我知道还有另一种方法来获取片段,但我想知道为什么我不能这样做。我猜版本有问题,因为我的类版本似乎比文档的版本旧,例如还有一个使用 FragmentManager 的额外构造函数,在文档中找不到。
甚至可能是最小 API 问题吗?我有24个。
Thanks.
它是从 1.4.0-alpha01 开始添加的(https://developer.android.com/jetpack/androidx/releases/fragment#1.4.0-alpha01 https://developer.android.com/jetpack/androidx/releases/fragment#1.4.0-alpha01)
如果您使用的是较低版本,则不会出现。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)