你的位置:首页 > 软件开发 > Java > getSupportFragmentManager要用在FragmentActivity及其子类中

getSupportFragmentManager要用在FragmentActivity及其子类中

发布时间:2016-04-11 19:00:06
getSupportFragmentManager要用在FragmentActivity及其子类中!! 关于安卓抽屉导航!! * 自定义侧边栏 创建一个Fragment:CarlozLibFragment.jav ...

getSupportFragmentManager要用在FragmentActivity及其子类中!!

 

关于安卓抽屉导航!!

 * 自定义侧边栏

 

getSupportFragmentManager要用在FragmentActivity及其子类中

 

 

 

getSupportFragmentManager要用在FragmentActivity及其子类中

 

      创建一个Fragment:CarlozLibFragment.java,并为其创建一个布局carloz_lib_webview.

 

getSupportFragmentManager要用在FragmentActivity及其子类中
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,    Bundle savedInstanceState) {  View root = inflater.inflate(R.layout.diy_slider_content, container, false);    root.findViewById(R.id.btnJump).setOnClickListener(new OnClickListener() {    @Override    public void onClick(View v) {      if (mDrawerLayout != null) {        // 隐藏侧边栏        mDrawerLayout.closeDrawer(mFragmentContainerView);      }      if(mCallbacks != null) {        mCallbacks.onGotoCarlozLibClicked();      }    }  });    return root;}
getSupportFragmentManager要用在FragmentActivity及其子类中

 

      onGotoCarlozLibClicked()这个接口是自定义接口,在 静态接口 NavigationDrawerCallbacks 中新增定义

 

getSupportFragmentManager要用在FragmentActivity及其子类中
@Overridepublic void onGotoCarlozLibClicked() {  // 需要实现 NavigationDrawerFragment.java Callback中新增的方法  // 在容器 container 中添加 fragment CarlozLibFragment  getSupportFragmentManager().beginTransaction()      .replace(R.id.container, new CarlozLibFragment())      .commit();}
getSupportFragmentManager要用在FragmentActivity及其子类中

 

运行结果如下:

 

getSupportFragmentManager要用在FragmentActivity及其子类中

 

这里引用:http://www.cnblogs.com/carlo/p/4726719.html

 


原标题:getSupportFragmentManager要用在FragmentActivity及其子类中

关键词:get

get
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录