gpt4 book ai didi

java - 在我的 FragmentContainerView 对象中找不到方法 getFragment()

转载 作者:行者123 更新时间:2023-12-04 23:39:10 24 4
gpt4 key购买 nike

在我有的 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" />
我想从 View 中获取 fragment 。 documentation建议使用
FragmentContainerView fcv = findViewById(R.id.identifications_map_view);
SupportMapFragment smf = fcv.getFragment()
但是 Android Studio 无法解析符号,如果我 CTRL+单击“FragmentContainerView”,当我使用 CTRL+F 搜索时它不会显示 getFragment()。
我知道还有另一种获取 Fragment 的方法,但我想知道为什么我不能这样做。我猜这个版本有问题,因为我似乎有一个比文档版本更旧的类,例如还有一个使用 FragmentManager 的额外构造函数,在文档中找不到。
它甚至可能是最小的 API 问题吗?我有 24 个。
谢谢。

最佳答案

它已从 1.4.0-alpha01 ( https://developer.android.com/jetpack/androidx/releases/fragment#1.4.0-alpha01 ) 添加
如果您使用的是较低版本,它将不存在。

关于java - 在我的 FragmentContainerView 对象中找不到方法 getFragment(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68018322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com