BlankFragment blankFragment = new BlankFragment();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction beginTransaction = fragmentManager.beginTransaction();
beginTransaction.add(R.id.frament,blankFragment); //第一个参数是需要加载在哪个布局控件,第二个是哪个碎片
beginTransaction.commit();
beginTransaction.add//添加
beginTransaction.remove//删除
beginTransaction.replace//替换
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
// return inflater.inflate(R.layout.fragment_blank, container, false);
View view = inflater.inflate(R.layout.fragment_blank, container, false);
return view;
}
在Fragment 文件里面,写上
静态就直接在name里面写上,不需要再加载
Fragment 动态加载 / 静态加载
最新推荐文章于 2023-03-10 16:34:29 发布