android-architecture-navigation

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

回眸只為那壹抹淺笑 提交于 2020-03-25 13:45:33
问题 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

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

两盒软妹~` 提交于 2020-03-25 13:45: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

Equivalent of startActivityForResult() with Android Architecture Navigation

喜你入骨 提交于 2020-03-17 05:34:24
问题 I have a workflow with 3 screens. From "screen 1" to access to "screen 2", the user must accept some kind of terms and conditions that I call in my picture "modal". But he only has to accept those conditions once. The next time he is on the first screen, he can go directly to screen 2. The user can chose to NOT accept the terms, and therefore we go back to "screen 1" and do not try to go to "screen 2". I am wondering how to do it with the new navigation component. Previously, what I would do

Android Navigation Component Not Displaying Fragment

▼魔方 西西 提交于 2020-03-16 06:22:27
问题 I'm trying to implement the new Android Navigation Component in an existing app. I have 2 fragments that are identical except for their name. When I set the startDestination to fragment2, the fragment seems to be shown correctly. When the startDestination is set to fragment1, I don't see the inflated view but I do see the "Fragment 1 created" toast. What am I doing incorrectly? class Fragment1 : Fragment() { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,

Set toolbar title dynamically using navigation-component

只愿长相守 提交于 2020-03-16 05:41:30
问题 I'm trying to set the toolbar title dynamically, I don't know if it's possible or not. Assume I have list of items every item I clicked it's open new fragment, thus I trying to change toolbar title for each item dynamically. I tried : it.findNavController().navigate(direction) it.findNavController().currentDestination!!.label = someTitle But it doesn't work. There are some related topics i.e: How to set title in app bar with Navigation Architecture Component But it doesn't solve my problem

Android NavigationUI startDestination class (not ID) programmatically

懵懂的女人 提交于 2020-03-04 18:57:21
问题 I need to set the start destination of a navigation graph programmatically depending on a condition. I have Fragment0, and also Fragment1, Fragment2, ... FragmentN all extending Fragment0, and being all of them (including Fragment0) able to be that wished start destination . I already know there is the method from NavGraph called setStartDestination(R.id.nav_fragment_X); but it is not useful for me because, if I am not wrong, it requires to have all these fragment0...N nodes declared in the

Android NavigationUI startDestination class (not ID) programmatically

陌路散爱 提交于 2020-03-04 18:56:49
问题 I need to set the start destination of a navigation graph programmatically depending on a condition. I have Fragment0, and also Fragment1, Fragment2, ... FragmentN all extending Fragment0, and being all of them (including Fragment0) able to be that wished start destination . I already know there is the method from NavGraph called setStartDestination(R.id.nav_fragment_X); but it is not useful for me because, if I am not wrong, it requires to have all these fragment0...N nodes declared in the

ViewPager2/Tabs problem with ViewModel state

ぐ巨炮叔叔 提交于 2020-02-29 13:23:23
问题 I am following the MVVM pattern - meaning I have a ViewModel for each Fragment. I added two tabs by using ViewPager2. My adapter looks like this: @Override public Fragment createFragment(int position) { switch (position) { case 0: return new MergedItemsFragment(); case 1: return new ValidatedMergedItemsFragment(); } return new MergedItemsFragment(); } The tabs are working. However, I noticed that the ViewModel of my MergedItemsFragment is behaving weirdly. Before I added tabs I navigated to

ViewPager2/Tabs problem with ViewModel state

浪尽此生 提交于 2020-02-29 13:21:13
问题 I am following the MVVM pattern - meaning I have a ViewModel for each Fragment. I added two tabs by using ViewPager2. My adapter looks like this: @Override public Fragment createFragment(int position) { switch (position) { case 0: return new MergedItemsFragment(); case 1: return new ValidatedMergedItemsFragment(); } return new MergedItemsFragment(); } The tabs are working. However, I noticed that the ViewModel of my MergedItemsFragment is behaving weirdly. Before I added tabs I navigated to

ViewPager2/Tabs problem with ViewModel state

ε祈祈猫儿з 提交于 2020-02-29 13:20:48
问题 I am following the MVVM pattern - meaning I have a ViewModel for each Fragment. I added two tabs by using ViewPager2. My adapter looks like this: @Override public Fragment createFragment(int position) { switch (position) { case 0: return new MergedItemsFragment(); case 1: return new ValidatedMergedItemsFragment(); } return new MergedItemsFragment(); } The tabs are working. However, I noticed that the ViewModel of my MergedItemsFragment is behaving weirdly. Before I added tabs I navigated to