android-architecture-navigation

Component Navigation , pop from backstack with arguments

落爺英雄遲暮 提交于 2019-12-11 04:25:06
问题 Let's say I have three fragments, A, B, C; A -> B <-> C Between B and C it is a circular relationship. Either B or C fragments requires arguments , example val args = Bundle() args.putString("StringKeyBC", argValueBtoC) findNavController().navigate(R.id.action_fragmentB_to_fragmentC, args, null) args.putString("StringKeyCB", argValueCtoB) findNavController().navigate(R.id.action_fragmentC_to_fragmentB, args, null) The problem is that every time I move between B & C, the fragments are added to

How to navigate from nested Fragment to parent fragment using Jetpack Navigation?

烈酒焚心 提交于 2019-12-10 16:48:04
问题 I have main navigation: SplashFragment -> RegistrationFragment -> RootFragment <fragment android:id="@+id/splashFragment" android:name="com.low6.low6.features.splash.SplashFragment" android:label="Splash" tools:layout="@layout/fragment_splash" > <action android:id="@+id/action_next" app:clearTask="true" app:destination="@id/registrationFragment" /> </fragment> <fragment android:id="@+id/registrationFragment" android:name="com.low6.low6.features.registration.RegistrationFragment" android:label

Navigation Architecture Fragment Reload Problem

给你一囗甜甜゛ 提交于 2019-12-10 16:46:22
问题 I am using Navigation Architecture in an image gallery, when I go from fragment A to B and then return back to A, these 3 methods are called again which will cause my gallery to reload , where I should load my data in fragment so when I come back from B to A my methods don't get called? : OnCreateView OnViewCreated OnResume 回答1: The fragment's lifecycle methods anyway will called again. You can google it how to work with fragment or activity lifecycle. The main idea how to deal with lifecycle

Why addDefaultArguments() removed from Navigation Component version 1.0.0-alpha09? What is WorkAround to pass arg to StartDestination from Activity?

谁说我不能喝 提交于 2019-12-10 15:13:37
问题 Hello i am working on Navigation Architecture Component and i and setting up NavHostFragment for my Activity programatically. MainActivity.xml : <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity">

Android Navigation Architecture Component: How to pass bundle data to startDestination

非 Y 不嫁゛ 提交于 2019-12-10 14:23:54
问题 I have an activity which has a NavHostFragment . The activity receives certain values in its intent. I want to pass this data to the first fragment i.e startDestination of the navigation graph. I couldn't find any documentation regarding this. I have already gone through this question on SO but I can't seem to find the addDefaultArguments method for navController.getGraph() . Is it possible to pass bundle to startDestination ? 回答1: i also came across same issue, This is how i resolved it:

Pass data back to previous fragment using Android Navigation

元气小坏坏 提交于 2019-12-10 13:35:17
问题 I've started using Android Architecture Components (Navigation and Safe Args, View Models) along with Koin library. Currently, I've got a problem with passing arguments between two fragments - I need to pass a string value from fragment A to fragment B, modify this value in fragment B and pass it back to fragment A. I've found one possible solution to my problem - shared view models. Unfortunately, this approach has one problem because I can pass and modify values between screens, but when

NavHostFragment not accessible from XML

一世执手 提交于 2019-12-09 16:45:12
问题 I wanted to try new Navigation library. After following this guideline I experienced error at runtime: Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class fragment Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment androidx.navigation.fragment.NavHostFragment: make sure class name exists, is

Android Jetpack Navigation library and onActivityResult

天涯浪子 提交于 2019-12-09 15:44:28
问题 I'm trying to migrate an app to the new Navigation Architecture Component that was announced at GoogleIO'18 Suppose I need to use an activity that is normally started with startActivityForResult . This activity comes either from a library or a system activity, so I can't modify it. Is there any way to include this activity as a destination in the navigation graph and get results from it? 回答1: The only solution I have so far is to wrap that activity behind a fragment that catches the result

How to set title in app bar with Navigation Architecture Component

荒凉一梦 提交于 2019-12-09 15:21:57
问题 I was trying out Navigation architecture component and is now having difficulties in setting the title. How do I set the title programmatically and also how it works? To clear my question, let's have an example, where, I've set up a simple app with MainActivity hosting the navigation host controller, the MainFragment has a button and on clicking the button it goes to DetailFragment . The same code from another question of multiple app bars on stack-overflow. MainActivity public class

Could not find androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01

限于喜欢 提交于 2019-12-09 05:09:11
问题 I want to use Navigation Architecture Components. But I got a problem with importing safeargs Sync message: Could not find androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01. Searched in the following locations: https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.pom https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01