Question: In my fragment\_main.xml, I have the following code :

```
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/nav_host_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toTopOf="@+id/bottomBar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph='@navigation/bottom_bar_nav_graph' />

  <!--custom bottom navigation ui-->

</androidx.constraintlayout.widget.ConstraintLayout>

```

I would like to have access to `navController(***bottom_bar_nav_graph***)` from fragment.
Is it possible?

Answer: 
If I get what you are trying to do correctly, you what to do something like

```
findViewbyId(R.id.bottom_bar_nav_graph)

```

which is not possible.

What this line of code is doing

```
app:navGraph='@navigation/bottom_bar_nav_graph' 

```

is to let `FragmentContainerView` know about your graph `bottom_bar_nav_graph`  which is an XML file that describes how your fragments relate, pass data and navigate between each other.

But can have access to `nav_host_fragment` which is the `id` for the host fragment.

If you want to access the navController with the id in Activity, you can use

```
val  navController = findNavController(R.id.nav_host_fragment)

```
```
extends Fragment {

    private static final String ARG_SECTION_NUMBER = "section_number";

    private PageViewModel pageViewModel;
    private FragmentMainBinding binding;

    public static PlaceholderFragment newInstance(int index) {
        PlaceholderFragment fragment = new PlaceholderFragment();
        Bundle bundle = new Bundle();
        bundle.putInt(ARG_SECTION_NUMBER, index);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        pageViewModel = new ViewModelProvider(this).get(PageViewModel.class);
        int index = 1;
        if (getArguments() != null) {
            index = getArguments().getInt(ARG_SECTION_NUMBER);
        }
        pageViewModel.setIndex(index);
    }

    @Override
    public View onCreateView(
            @NonNull LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        binding = FragmentMainBinding.inflate(inflater, container, false);
        View root = binding.getRoot();

        final TextView textView = binding.sectionLabel;
        pageViewModel.getText().observe(getViewLifecycleOwner(), new Observer<String>() {
            @Override
            public void onChanged(@Nullable String s) {
                textView.setText(s);
            }
        });
        return root;
    }

```