chaychan / BottomBarLayout

(一个轻量级的底部导航控件)A simple and lightly widget to accomplish bottom Navigation,可设置未读数、提示点、提示消息
954 stars 193 forks source link

怎样和fragment关联? #31

Open EHENJOOM opened 5 years ago

AnserBaby commented 4 years ago

`private void changeFragment(int currentPosition) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

    switch (currentPosition) {
        case 0:
            //tabImageView1.setColorFilter(color);

            if (homeFragment == null) {
                homeFragment = new HomeFragment();
            }
            transaction.replace(R.id.fl_content, homeFragment);

            break;
        case 1:
            //tabImageView2.setColorFilter(color);

            if (videoFragment == null) {
                videoFragment = new VideoFragment();
            }
            transaction.replace(R.id.fl_content, videoFragment);
            break;
        case 2:
            //tabImageView3.setColorFilter(color);

            if (aboutFragment == null) {
                aboutFragment = new AboutFragment();
            }
            transaction.replace(R.id.fl_content, aboutFragment);
            break;
        default:
            break;
    }
    //transaction.replace(R.id.fl_content, mFragmentList.get(currentPosition));
    transaction.commit();
}`

这个方法里改成这样,要新建homeFragment,videoFragment,aboutFragment,这三个XML文件