I am new to Android Development, I'm creating an e-learning app and I've come across a problem grasping the concept of navigation component and fragments. As of now, I've managed to create and understand how to create and modify the navigation drawer menu using navController, AppbarLayout and toolbars using the default template navigation drawer that the android studio provided.
Now, I have this cardview (which is in a fragment) which contains several information about Word of the Day. What I want to do is when I click this cardview it will go to another fragment which is the (word of the day) fragment. I've managed to do it using the navigate using ID from the official android developers site https://developer.android.com/guide/navigation/navigation-navigate this is what I used, this code is in the fragment class of where the cardview resides
CardView card_fsl_resource = views.findViewById(R.id.card_fsl_resource);
card_fsl_resource.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Navigation.findNavController(view).navigate(R.id.nav_fsl_wotd);
}
});
I found my luck however here comes the problem, below is an attached yt video that shows the bug. https://www.youtube.com/watch?v=K4XymJ_h2_4 when i click the cardview it goes to the intended fragment however i cannot go back to the previous fragment using navigation drawer, when i click the previous fragment via menu of navigation drawer, it only goes to the fragment of word of the day. I even tried using fragment manager specified here Navigate from one fragment to another on click of a button but it is not working.
i'll attach my project repository, if you want to see it for yourself. https://github.com/Jayveeeee24/iSpeakSigns