Home > Mobile >  I have only a Single Activity in my Android Project and I want to show different type of Menu in dif
I have only a Single Activity in my Android Project and I want to show different type of Menu in dif

Time:01-03

My Android Projects implements only One activity and others are all Fragments. So, for example i have 5 Fragments, I want 3 of them having a BottomNavigation menu while the other 2 to have TabLayout menu. How can i do that? I saw some people say create an Interface and let my MainActivity implement the Interface, then make changes to Activity from Fragment through Interface. Is this the best choice/practice? What other options is available and which is the best?

CodePudding user response:

You can try to implement it using Jetpack Navigation component, it will be easier to handle.

Check the official document

CodePudding user response:

An interface is not necessary to handle this usecase. You can create both Views in your Activity and simply set the visibility when you create a new Fragment. view.visibility = View.VISIBLE view.visibility = View.GONE.

  • Related