1. 代码:
FragmentFactory factory = mManager.getFragmentFactory(); fragment =
factory.instantiate(mContext.getClassLoader(), className);
2.原因:(它建议开发者自定义工厂类来实例化Fragments,这个instantiateFragment() needed to maintain
forward compatibility)
/** * Instantiates the Fragment via the FragmentManager's * {@link
androidx.fragment.app.FragmentFactory}. * * Note that this method is
<strong>not</strong> responsible for calling * {@link
Fragment#setArguments(Bundle)} on the returned Fragment instance. * * @param
context Context providing the correct {@link ClassLoader} * @param
fragmentManager FragmentManager the Fragment will be added to * @param
className The Fragment to instantiate * @param args The Fragment's arguments,
if any * @return A new fragment instance. * @deprecated Set a custom {@link
androidx.fragment.app.FragmentFactory} via * {@link
FragmentManager#setFragmentFactory(FragmentFactory)} to control * instantiation
of Fragments. */ @SuppressWarnings("DeprecatedIsStillUsed") // needed to
maintain forward compatibility @Deprecated @NonNull public Fragment
instantiateFragment(@NonNull Context context, @NonNull FragmentManager
fragmentManager, @NonNull String className, @SuppressWarnings("unused")
@Nullable Bundle args) { return
fragmentManager.getFragmentFactory().instantiate( context.getClassLoader(),
className); }
 

 

技术
©2019-2020 Toolsou All rights reserved,
Java中的lambda表达式如何理解——精简html+css+js制作简单网站首页java作业VHDL——4选1数据选择器C++OpenCV实战——车牌去雾、车牌检测、分割JAVA阶段考内容知识点的梳理计算机组成原理的简单学习java连接数据库实现基本的增删改查2022年第十三届蓝桥杯题解(全)3 4j不是合法的python表达式_3+4j不是合法的Python表达式。