首页 > 学院 > 开发设计 > 正文

Fragment初始化

2019-11-09 18:00:56
字体:
来源:转载
供稿:网友

1.继承Fragment,重写onCreateView和onActivityCreate方法 2.在MainActivity中初始化Fragment

FragmentManager fm = getSupportFragmentManager();//继承FragmentActivityFragmentTransaction transaction = fm.beginTransaction(); transaction.replace(R.id.fl_left_menu, new LeftMenuFragment(), TAG_LEFT_MENU);transaction.replace(R.id.fl_content, new ContentFragment(), TAG_CONTENT);transaction.commit();
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表