android-architecture-navigation

Accessing graph-scoped ViewModel of child NavHostFragment using by navGraphViewModels

南笙酒味 提交于 2019-12-13 03:35:08
问题 I am using the Navigation Component of Android Jetpack (2.2.0-alpha01). I wish to use a child NavHostFragment nested inside my main NavHostFragment, equipped with its own child nav graph. Please view the following image for context: The child nav host is defined like this inside the fragment that is at the front of the MainNavHost's stack: <fragment android:id="@+id/childNavHostFragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android

Get Backstack status using android navigation component

橙三吉。 提交于 2019-12-12 10:36:42
问题 I want to implement backpress behaviour such that it prompts a confirmation popup when you press back with the backstack empty, otherwise it pops the next fragment in the stack. I'm trying to get the backstack count, but i always get 0 from both fragment managers getSupportFragmentManager().getBackStackEntryCount(); getFragmentManager().getBackStackEntryCount(); I guess it should work since i checked the google code of fragment navigator and it adds to backstack through the canonical fragment

Ignoring navigate() call: FragmentManager has already saved its state

為{幸葍}努か 提交于 2019-12-12 09:38:25
问题 I'm using navigation in MainActivity , then I start SecondActivity (for result). After finish of SecondActivity I would like to continue with navigation in MainActivity , but FragmentManager has saved his state already. On Navigation.findNavController(view).navigate(R.id.action_next, bundle) I receive log message: Ignoring navigate() call: FragmentManager has already saved its state How I can continue in navigation? 回答1: You must always call super.onActivityResult() in your Activity's

How to set target fragment of a dialog when using navigation components

大兔子大兔子 提交于 2019-12-12 08:31:17
问题 I'm showing a dialog inside a fragment using childFragmentManager or within an Activity using the supportFragmentManager , in the process I would like to set the target fragment, like this: val textSearchDialog = TextSearchDialogFragment.newInstance() textSearchDialog.setTargetFragment(PlaceSearchFragment@this, 0) But when running that code I get the error: java.lang.IllegalStateException: Fragment TextSearchDialogFragment{b7fce67 #0 0} declared target fragment PlaceSearchFragment{f87414 #0

Android Navigation Component: java.lang.IllegalStateException: unknown destination during restore

蓝咒 提交于 2019-12-11 17:47:09
问题 I'm using Android's AAC Navigation Component and have implemented conditional navigation for my login flow as described in this post: Navigation Architecture Component - Login screen Now everything appears to be working, however after being navigated to the login screen and successfully logging in then navigating back to the main screen, on rotation the app crashes with the following error: --------- beginning of crash 2019-02-02 13:08:28.423 6030-6030/uk.co.victoriajanedavis.chatapp E

How to navigate to Half Fragment ? (Navigation Architecture Component)

六月ゝ 毕业季﹏ 提交于 2019-12-11 17:39:58
问题 I am trying Navigation architecture Component in My app. Earlier i Used Fragment Transaction's to achieve the below feature. Basically i want to navigate from. FragmentA->FragmentB (custom fragment partially transparent and half of screen size) If i am using Navigation component and try Navigation.findNavController(view).navigate(R.id.action_FragmentA_to_FragmentB) Then the result is the FragmentA is replaced by FragmentB and the background fragment is not visible. I want to know of a

Navigation component no transitions to select in drop down

巧了我就是萌 提交于 2019-12-11 10:52:25
问题 I created navigation folder and navigation .xml file but in the navigation component under Animations->Enter there is no animations to choose from. 回答1: In the gradle you should add those lines under dependencies: def nav_version = "1.0.0-rc02" implementation "android.arch.navigation:navigation-fragment:$nav_version" implementation "android.arch.navigation:navigation-ui:$nav_version" 来源: https://stackoverflow.com/questions/55185964/navigation-component-no-transitions-to-select-in-drop-down

Why Dialog does not have a NavController [Missing]?

扶醉桌前 提交于 2019-12-11 08:47:12
问题 I am trying to use the latest update of Nav Component in my application where i can add dialog( BottomSheetDialogFragment ) in my nav graph nav_version = "2.1.0-alpha05" Part of code from my nav_graph : <dialog android:id="@+id/settingFragment" android:name="com.andor.navigate.notepad.listing.fragment.SettingFragment" tools:layout="@layout/fragment_setting"> <action android:id="@+id/action_settingFragment_to_confirmationFragment" app:destination="@id/confirmationFragment" /> </dialog> <dialog

Is it possible to use androidx-navigation with onClick-databinding without writing boilercode in Fragment?

核能气质少年 提交于 2019-12-11 07:33:25
问题 I want to implement an androidx-navigation by using databinding instead of implementing onClick handler in code I have a List-fragment with a livedata element selectedItemId and want to open a correspondeng detail-fragment when pressing the edit button. Is something similar to this possible <layout> <data> <!-- assuming that com.example.MyGeneratedNavigation was generated from .../res/navigation/my_navigation.xml --> <variable name="myNavigation" type"com.example.MyGeneratedNavigation" />

Bottom App Bar slide up/down on navigating with fragments (Navigation Architecture Components)

流过昼夜 提交于 2019-12-11 05:18:51
问题 I was having a look at the Bottom App Bar and there is a nice feature to hide it on scroll app:hideOnScroll="true" . The problem it that I cannot figure it out how to slide it up or down progmatically when the fragments are being navigated to and from . For example, overview of a setup: on MainActivity has the navigation host fragment and it is hosting a MainFragment and a DetailFragment . The MainFragment has a RecyclerView , which on scroll, will hide the Bottom App Bar . On clicking any