点击RadioGroup切换Fragment(不能滑动切换)

frame是FrameLayout布局
manager = getSupportFragmentManager();
manager.beginTransaction().add(R.id.frame,list_fragment.get(0)).commit();
radio_group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(RadioGroup radioGroup, int i) {
        switch (i){
            case R.id.rb1:
                manager.beginTransaction().replace(R.id.frame,list_fragment.get(0)).commit();
                break;
            case R.id.rb2:
                manager.beginTransaction().replace(R.id.frame,list_fragment.get(1)).commit();
                break;
            case R.id.rb3:
                manager.beginTransaction().replace(R.id.frame,list_fragment.get(2)).commit();
                break;
            case R.id.rb4:
                manager.beginTransaction().replace(R.id.frame,list_fragment.get(3)).commit();
                break;
        }
    }
});

你可能感兴趣的:(点击RadioGroup切换Fragment(不能滑动切换))