android-architecture-navigation

how to remove back button in the toolbar of top level fragment if I set toolbar in each fragment using navigation component?

℡╲_俬逩灬. 提交于 2020-04-17 21:56:19
问题 I have tried to read this but my problem is little bit different. I need some different toolbars, so according the documentation from here , I need to set the toolbar in each of my fragment not in my MainActivity. so I set the toolbar in each xml of my fragment. and then in each fragment I use this code to set the toolbar override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val toolbar = view.findViewById<androidx.appcompat.widget

Navigation components - Mocking Navcontroller graph

我只是一个虾纸丫 提交于 2020-04-16 03:47:47
问题 I'm using navigation components and I'm trying to test my Fragment with instrumented test. The fragment has a custom toolbar initialized in onViewCreated method by an extension function. override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) tbBlack.init() } fun androidx.appcompat.widget.Toolbar.init( menuId: Int? = null ) { title = "" menuId?.let { inflateMenu(it) } findNavController().let { it.graph.let { graph -> val

Navigation components - Mocking Navcontroller graph

北城余情 提交于 2020-04-16 03:47:09
问题 I'm using navigation components and I'm trying to test my Fragment with instrumented test. The fragment has a custom toolbar initialized in onViewCreated method by an extension function. override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) tbBlack.init() } fun androidx.appcompat.widget.Toolbar.init( menuId: Int? = null ) { title = "" menuId?.let { inflateMenu(it) } findNavController().let { it.graph.let { graph -> val

Avoiding Android navigation IllegalArgumentException in NavController

感情迁移 提交于 2020-04-12 09:31:30
问题 I recently switched over to Android Navigation, but have encountered a fair amount of situations (in different parts of the code), where I get: Fatal Exception: java.lang.IllegalArgumentException navigation destination com.xxx.yyy:id/action_aFragment_to_bFragment is unknown to this NavController In every case, the code are simple calls like: findNavController(this, R.id.navigation_host_fragment).navigate(R.id.action_aFragment_to_bFragment) Usually in response to a button press. It's unclear

How to use Navigation Drawer and Bottom Navigation simultaneously - Navigation Architecture Component

和自甴很熟 提交于 2020-04-10 07:54:32
问题 I have screen like below which contain a navigation drawer and bottom navigation on same screen: I am using Jetpack Navigation Architecture Component. Current issue and What I have tried? Clicking on the 2nd and 3rd bottom nav item shows back arrow on toolbar? Tried: setting fragments associated with 2nd and 3rd bottom nav to top level destinations appBarConfig = AppBarConfiguration(setOf(R.layout.fragment_star, R.layout.fragment_stats, R.layout.fragment_user)) instead of appBarConfig =

How to use Android Navigation Component + BottomNavigationView+ NavigationView (Navigation Drawer)

自闭症网瘾萝莉.ら 提交于 2020-04-10 03:31:31
问题 I would like to know what is the best practice of using Navigation Component + BottomNavigationView + NavigationDrawer. I have tried google's advanced sample for Navigation component. It worked very well for multiple back stack modules. Because it has a workaround extension. When using this approach, each bottom tab has its own graph and the graphs change as you select one of the tabs. But when NavigationView is integrated, it needs to know the navigation graph in advance. But in advanced

How to use Android Navigation Component + BottomNavigationView+ NavigationView (Navigation Drawer)

可紊 提交于 2020-04-10 03:30:27
问题 I would like to know what is the best practice of using Navigation Component + BottomNavigationView + NavigationDrawer. I have tried google's advanced sample for Navigation component. It worked very well for multiple back stack modules. Because it has a workaround extension. When using this approach, each bottom tab has its own graph and the graphs change as you select one of the tabs. But when NavigationView is integrated, it needs to know the navigation graph in advance. But in advanced

ViewPager with two tabs causes IndexOutOfBoundsException when sliding and clicking

放肆的年华 提交于 2020-04-03 10:41:05
问题 I have two tabs in which I add two different lists of data, both tabs share a single recyclerview, so at my viewpager adapter, I just create a new instance to populate the data From the View val allProducts = completeProductList val productsList = mutableListOf<Products>() val drinksList = mutableListOf<Products>() for (product in allProducts) { if (product.isDrink) { drinksList.add(product) } else { productsList.add(product) } } viewPagerAdapter.productsList = productsList viewPagerAdapter

SharedViewModel from viewpager2 and my parent Fragment

不打扰是莪最后的温柔 提交于 2020-03-25 17:56:31
问题 So, I have one fragment, lets call it Fragment A, in which I need it to be the main host of my sharedviewmodel. So I have it like this class FragmentA:Fragment() { private val model: SharedViewModel by viewModels() } Now, inside Fragment A, I set viewpager2 Adapter private fun setupViewPagerWithTabLayout( productList: MutableList<Producto>, drinkList: MutableList<Producto> ) { val fragmentList = listOf( FragmentProducts.newInstance(productList), FragmentProducts.newInstance(drinkList))

still have error no current navigation node even after using navigation 2.2.1

痞子三分冷 提交于 2020-03-25 13:46:02
问题 I have tried to read this but it doesn't solve my issue so I navigate to next destination using this code val nextDirection = CreateEventNameFragmentDirections.actionToCreateEventType(userKM, newEvent) findNavController().navigate(nextDirection) but it crash after I rotate the device with error java.lang.IllegalStateException: no current navigation node i update the gradle using this implementation 'android.arch.navigation:navigation-fragment-ktx:2.2.1' implementation 'android.arch.navigation