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,
判断当前对象是不是数组的4种方式keras数据生成器--数据增强作弊器开发商致歉java中的编译时异常和运行时异常ajax get请求中文参数乱码解决Vue el-select 获取label值MySql语句 递归寻找某输入部门的所有下级部门vue 监听 Treeselect 选择项的改变rk3399_android7.1调试USB蓝牙模块小结(精华2020年6月3日更新) TypeScript中接口详解