navigation-architecture

How to handle multiple NavHosts/NavControllers?

无人久伴 提交于 2021-02-06 09:31:50
问题 I'm having a problem when dealing with multiple NavHosts. This issue is very similar to the one asked here. I think the solution for this question would help me as well, but it's a post from 2017 and it still has no answer. Android Developers Documentation doesn't help and searching through the web shows absolutely nothing that could possibly help. So basically I have one Activity and two Fragments. Let's call them FruitsActivity, FruitListFragment, FruitDetailFragment, where FruitsActivity

How to Navigate any destination for action of header of drawer in navigation architecture

蹲街弑〆低调 提交于 2021-02-05 11:31:54
问题 Anyone please explain, How to define the action in Navigation architecture for header layout of drawer. Now, I need to set click of header of drawer and I set it to like this: headerOfNavDrawer.setOnClickListener{ //Here I want to navigate to editProfileFragment //But For navigation I need an action in nav arch graph. //Where to put action?? } 回答1: You have two things you need: A reference to the NavController . As per the Navigate to a destination documentation, you can use findNavController

How to Navigate any destination for action of header of drawer in navigation architecture

梦想的初衷 提交于 2021-02-05 11:31:11
问题 Anyone please explain, How to define the action in Navigation architecture for header layout of drawer. Now, I need to set click of header of drawer and I set it to like this: headerOfNavDrawer.setOnClickListener{ //Here I want to navigate to editProfileFragment //But For navigation I need an action in nav arch graph. //Where to put action?? } 回答1: You have two things you need: A reference to the NavController . As per the Navigate to a destination documentation, you can use findNavController

Why not work back button with android navigation component

痴心易碎 提交于 2021-01-20 12:34:35
问题 this my Auth Activity class AuthActivity : AppCompatActivity() { private lateinit var navController: NavController override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val binding = ActivityAuthBinding.inflate(layoutInflater) setContentView(binding.root) navController = Navigation.findNavController(this, fragment.id) NavigationUI.setupActionBarWithNavController(this, navController) } override fun onSupportNavigateUp(): Boolean { return NavigationUI

Why not work back button with android navigation component

我与影子孤独终老i 提交于 2021-01-20 12:34:32
问题 this my Auth Activity class AuthActivity : AppCompatActivity() { private lateinit var navController: NavController override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val binding = ActivityAuthBinding.inflate(layoutInflater) setContentView(binding.root) navController = Navigation.findNavController(this, fragment.id) NavigationUI.setupActionBarWithNavController(this, navController) } override fun onSupportNavigateUp(): Boolean { return NavigationUI

Why not work back button with android navigation component

跟風遠走 提交于 2021-01-20 12:34:09
问题 this my Auth Activity class AuthActivity : AppCompatActivity() { private lateinit var navController: NavController override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val binding = ActivityAuthBinding.inflate(layoutInflater) setContentView(binding.root) navController = Navigation.findNavController(this, fragment.id) NavigationUI.setupActionBarWithNavController(this, navController) } override fun onSupportNavigateUp(): Boolean { return NavigationUI