android.support.v4.app.FragmentTransaction required

前端 未结 6 1505
别跟我提以往
别跟我提以往 2021-02-05 03:54

entering in code like this:

FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

comes up with this error \"androi

6条回答
  •  醉话见心
    2021-02-05 04:34

    Ok...Just make a method for fragment and call this Like:

    void addfragment(Fragment fragment, boolean addBacktoStack, int transition) {
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.simple_fragment, fragment);
        ft.setTransition(transition);
        if (addBacktoStack)
            ft.addToBackStack(null);
        ft.commit();
    
    }
    

    Now Just call Your Fragment:

    addfragment(new DescriptionFragment(this),true, FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    

提交回复
热议问题