android-architecture-navigation

Unclude fragment from Backstack using Navigation component

我的未来我决定 提交于 2020-02-25 07:00:47
问题 I have Fragments X, A, B, and i'm using Navigation architecture component to navigate between them. Fragments A, B specific, but Fragment X can be any(C,D,...); Fragments A and B from Bottom Navigation and their "navigations icons" always on the screen, it means user can go to A or B anytime from any Fragment(include A and B): X -> A -> B X -> B -> A A -> B -> X A -> B -> A //another ways My problem about this case: X -> A -> B -> A -> B -> ? If user started from X , reached ? and begin to go

Conditional back navigation with Android Navigation Component

一个人想着一个人 提交于 2020-02-21 14:15:14
问题 Im making navigation in my app using navigation component from jetpack. I have 3 screens in my app, all of them implemented via Fragment: - search screen - list screen - detail screen When user presses search (on search screen ), app navigates to list screen loads results and displays them. User selects one of the results and navigates to detail screen . If there is only one result, app navigates from list screen to detail screen automatically, effectively skipping list screen. The problem is

Navigating from click listener in a row to another fragment

人盡茶涼 提交于 2020-02-21 05:48:44
问题 I need to click the button in Fragment A to Navigate to Fragment C am using Navigation Component , Data binding and Android ViewModel row.xml <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:padding="@dimen/padding"> <androidx.appcompat.widget

Navigating from click listener in a row to another fragment

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-21 05:48:31
问题 I need to click the button in Fragment A to Navigate to Fragment C am using Navigation Component , Data binding and Android ViewModel row.xml <?xml version="1.0" encoding="utf-8"?> <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:padding="@dimen/padding"> <androidx.appcompat.widget

injecting viewmodel with navigation-graph scope: NavController is not available before onCreate()

梦想的初衷 提交于 2020-02-15 00:22:42
问题 I'm using a navigation-component in my application and also using shared ViewModel between multiple fragments that are in the same graph. Now I want to instantiate the ViewModel with this graph scope with this. As you know, in fragments we should inject objects ( ViewModel,..etc ) in onAttach: but when I want to do this (injecting ViewModel with a graph scope in onAttach ), this error occurs: IllegalStateException: NavController is not available before onCreate() Do you how can I do this? 回答1

injecting viewmodel with navigation-graph scope: NavController is not available before onCreate()

此生再无相见时 提交于 2020-02-15 00:21:08
问题 I'm using a navigation-component in my application and also using shared ViewModel between multiple fragments that are in the same graph. Now I want to instantiate the ViewModel with this graph scope with this. As you know, in fragments we should inject objects ( ViewModel,..etc ) in onAttach: but when I want to do this (injecting ViewModel with a graph scope in onAttach ), this error occurs: IllegalStateException: NavController is not available before onCreate() Do you how can I do this? 回答1

injecting viewmodel with navigation-graph scope: NavController is not available before onCreate()

老子叫甜甜 提交于 2020-02-15 00:20:10
问题 I'm using a navigation-component in my application and also using shared ViewModel between multiple fragments that are in the same graph. Now I want to instantiate the ViewModel with this graph scope with this. As you know, in fragments we should inject objects ( ViewModel,..etc ) in onAttach: but when I want to do this (injecting ViewModel with a graph scope in onAttach ), this error occurs: IllegalStateException: NavController is not available before onCreate() Do you how can I do this? 回答1

Navigation Components: Switch Menu of Navigation Drawer (for logged in users)

跟風遠走 提交于 2020-02-06 08:16:51
问题 I am using the new Navigation Components library. I have a Navigation Drawer in place that works perfectly fine. If my user logs in I want to change the menu of the Navigation Drawer. Specifically, I want to change the "Login" item to "Logout" from within a fragment. All the solutions I found online didn't use Navigation Components. So therefore, they recommended something like this: // Get the navigationView and swap the menu NavigationView navigationView = view.findViewById(R.id.nav_view);

BottomAppBar with BottomNavigationDrawer connected to NavigationController

≡放荡痞女 提交于 2020-01-31 18:31:28
问题 Hi I'm trying to use new arch components in my project. Short description what I want to achive: When user is on MainFragment I want to display navigation icon (Hamburger) on BottomAppBar. User is able to click navigation icon and display BottomNavigationDrawer When user select some menu item, or click something on MainFragment he is moved to another fragment, let say DebtDetailsFragment . Then Hamburger should be replaced with 'Back arrow' by NavigationController Below I pasted my

How to remove back button from toolbar when using bottom menu bar with navigation architecture components

浪尽此生 提交于 2020-01-22 02:42:31
问题 I have an application which has a bottom menu bar which users can use to switch between 4 home page tabs. It's working fine like below. The only problem I'm having is it showing back button when I switch between different fragment. Since all these fragments are at the same level I do not want it to behave like that. This is my implementation. MainNavigationActivity class MainNavigationActivity : AppCompatActivity() { private lateinit var navigationController: NavController override fun