Fragment

作者: 烟入墨 | 来源:发表于2017-07-27 14:00 被阅读0次

    radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

    @Override

    public void onCheckedChanged(RadioGroup group, int checkedId) {

    // TODO Auto-generated method stub

    switch (checkedId) {

    case R.id.but01:

    //创建FragmentManager管理者

    FragmentManager fragmentManager=getSupportFragmentManager();

    //通过FragmentManager开启一个事务

    FragmentTransaction transaction=fragmentManager.beginTransaction();

    //加载fragment  arg0  占位的控件  第二个参数是加载的Fragment

    transaction.replace(R.id.fragment, new Fragment01());

    //提交

    transaction.commit();

    break;

    case R.id.but02:

    FragmentManager fragmentManager2=getSupportFragmentManager();

    FragmentTransaction transaction2=fragmentManager2.beginTransaction();

    transaction2.replace(R.id.fragment, new Fragment02());

    transaction2.commit();

    break;

    case R.id.but03:

    FragmentManager fragmentManager3=getSupportFragmentManager();

    FragmentTransaction transaction3=fragmentManager3.beginTransaction();

    transaction3.replace(R.id.fragment, new Fragment03());

    transaction3.commit();

    break;

    default:

    break;

    }

    }

    });

    相关文章

      网友评论

          本文标题:Fragment

          本文链接:https://www.haomeiwen.com/subject/cudgkxtx.html