Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎样和fragment关联? #31

Open
EHENJOOM opened this issue Jan 25, 2019 · 1 comment
Open

怎样和fragment关联? #31

EHENJOOM opened this issue Jan 25, 2019 · 1 comment

Comments

@EHENJOOM
Copy link

No description provided.

@AnserBaby
Copy link

`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文件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants