FragmentManager中缺少FragmentFactory类和getFragmentFactory()方法



我正在尝试为我的应用程序实现分层多屏幕设置。我正在遵循"整理你的设置"指南,其中包含一个函数的示例实现,该函数应该使用FragmentFactory类构造一个新的Fragment实例:

val fragment = supportFragmentManager.fragmentFactory.instantiate(
classLoader,
pref.fragment,
args)

但是,IDE既不能解析此类,也不能解析FragmentManagerfragmentFactory属性。

我正在使用以下支持库:

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.preference:preference:1.0.0'
implementation 'androidx.fragment:fragment-ktx:1.0.0'

该指南是否可能涉及尚未稳定的功能?

事实证明,这个类在androidx.fragment中从1.1.0版本开始就可用。目前它仍在alpha中,我只在生产中使用稳定的lib版本。

相关内容

  • 没有找到相关文章

最新更新