0

I was following the implementation of Navigation graph with multiple top level destinations in the question that was asked in the following link in stack overflow: Navigation graph with multiple top level destinations

According to the second answer, a set of top level destinations were created at first

val topLevelDestinations = setOf(R.id.garden_fragment,
        R.id.plant_list_fragment)
appBarConfiguration = AppBarConfiguration.Builder(topLevelDestinations)
        .setDrawerLayout(drawerLayout)
        .build()

The problem am having is that the code is in Kotlin, i understand how to implement the following part of the code in java


appBarConfiguration = AppBarConfiguration.Builder(topLevelDestinations)
        .setDrawerLayout(drawerLayout)
        .build()

The problem is that I don't know how to implement the first part of the code in java, this one

val topLevelDestinations = setOf(R.id.garden_fragment,
        R.id.plant_list_fragment)

Emmanuel Njorodongo
  • 1,004
  • 17
  • 35

1 Answers1

0

Use a simple Set<> with your top level destinations

navController = Navigation
            .findNavController(binding.navHostFragment);
    Set<Integer> topLevelDestinations = new HashSet<>();
    topLevelDestinations.add(R.id.garden_fragment);
    topLevelDestinations.add(R.id.plant_fragment);
    topLevelDestinations.add(R.id.settingsFragment);
    appBarConfiguration = new AppBarConfiguration.Builder(topLevelDestinations).build();
    NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);