Tuesday, 23 May 2023

Android Navigation Component load 2 nested Fragments into Parent Fragment

I have a Comparator Screen which is a Fragment that is splitted into 2 sub-screens. Before using Navigation Component I could easily just:

 private void initializeFragments() {

        FoodComparatorFragment comparatorFragment1 = new FoodComparatorFragment();
        FoodComparatorFragment comparatorFragment2 = new FoodComparatorFragment();

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.add(R.id.comparator_fragment_1, comparatorFragment1);
        transaction.add(R.id.comparator_fragment_2, comparatorFragment2);

        transaction.commit();
    }

However, I dont know how I should perform this operation with the Navigation Component WITHOUT using explicitly the FragmentManager.



from Android Navigation Component load 2 nested Fragments into Parent Fragment

No comments:

Post a Comment