Answer the question
In order to leave comments, you need to log in
How to change setDisplayShowHomeEnabled(true) in different fragments?
There is an activity that holds a fragment, if I create a backarrow in an activity, then it is created in all the fragments that change in it. I need this button to not be in the very first fragment, and when I move to other fragments, it appears. Tried tracking through fragmentManager.backStackEntryCount but the button just doesn't show up. It appears only when I create it in mainactivity in mainactivity.
Or can it only be done in a bush bar?
Answer the question
In order to leave comments, you need to log in
I clambered a lot of sources, but nevertheless I found a solution from an Indian in a video on YouTube.
//MainActivity
private lateinit var navController:NavController
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
navController=Navigation.findNavController(this,R.id.fragment)
NavigationUI.setupActionBarWithNavController(this,navController)
}
override fun onSupportNavigateUp(): Boolean {
return navController.navigateUp()
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question