android-architecture-navigation

Navigation Component: how to navigate from activity to a fragment

做~自己de王妃 提交于 2021-02-19 03:02:32
问题 I want to navigate on click FAB in (activity) to New fragment 1. in my code fab button in the main activity common for all pages. could anyone guide me? activity.xml <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout 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

Navigate up by back button with Navigation Component

穿精又带淫゛_ 提交于 2021-02-13 17:34:25
问题 I use navigation components to navigate from one fragment to another. However, when the user press the back button, I want to navigate back to first fragment. But it keep showing the second fragment. This is my nav_graph: <?xml version="1.0" encoding="utf-8"?> <navigation 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:id="@+id/nav_graph" app:startDestination="@id/fragment1">

How to add animation transition to NavigationUI in android?

元气小坏坏 提交于 2021-02-11 07:19:22
问题 i'm using NavigationUI to tie destinations to menu items, but how to override the default animation transition? Based on the doc https://developer.android.com/topic/libraries/architecture/navigation/navigation-ui#Tie-navdrawer, i cant find any method that can add the animation transition. 回答1: NavigationUI does not offer that API. However, there's absolutely no requirement to use NavigationUI - it is only optional helper methods. Therefore you can copy / build a simplified version of what it

How to add animation transition to NavigationUI in android?

ぐ巨炮叔叔 提交于 2021-02-11 07:17:58
问题 i'm using NavigationUI to tie destinations to menu items, but how to override the default animation transition? Based on the doc https://developer.android.com/topic/libraries/architecture/navigation/navigation-ui#Tie-navdrawer, i cant find any method that can add the animation transition. 回答1: NavigationUI does not offer that API. However, there's absolutely no requirement to use NavigationUI - it is only optional helper methods. Therefore you can copy / build a simplified version of what it

Object is changed after sending it to another Fragment

回眸只為那壹抹淺笑 提交于 2021-02-11 06:16:48
问题 So, I have a really weird issue, I pass an object from Fragment A to Fragment B , I modify this object in a new instance in Fragment B, but after I change a value on this object it also changes that value when I pop Framgment B and that object keeps modified now also for Fragment A Fragment A ... override fun onItemClick(v: View?, position: Int) { searchView.clearFocus() val bundle = Bundle() bundle.putSerializable("shop", landingAdapter.getItem(position)) findNavController().navigate(R.id

Object is changed after sending it to another Fragment

旧城冷巷雨未停 提交于 2021-02-11 06:16:48
问题 So, I have a really weird issue, I pass an object from Fragment A to Fragment B , I modify this object in a new instance in Fragment B, but after I change a value on this object it also changes that value when I pop Framgment B and that object keeps modified now also for Fragment A Fragment A ... override fun onItemClick(v: View?, position: Int) { searchView.clearFocus() val bundle = Bundle() bundle.putSerializable("shop", landingAdapter.getItem(position)) findNavController().navigate(R.id

Object is changed after sending it to another Fragment

情到浓时终转凉″ 提交于 2021-02-11 06:16:07
问题 So, I have a really weird issue, I pass an object from Fragment A to Fragment B , I modify this object in a new instance in Fragment B, but after I change a value on this object it also changes that value when I pop Framgment B and that object keeps modified now also for Fragment A Fragment A ... override fun onItemClick(v: View?, position: Int) { searchView.clearFocus() val bundle = Bundle() bundle.putSerializable("shop", landingAdapter.getItem(position)) findNavController().navigate(R.id

How to navigate fragment without adding it into backstack with NavController?

守給你的承諾、 提交于 2021-02-08 12:00:56
问题 NavController has methods navigate which navigate by default with backstack. How to navigate to the fragment without having backstack? Please note that, I am not asking about FragmentTransaction 回答1: If you have a back stack of: A -> B And want to get to a back stack of A -> C You can do a 'replace' operation by popping B off the back stack and adding C. In Navigation, this is done by using app:popUpTo (and optionally app:popUpToInclusive="true" if needed) to the <action> in your XML or by

Failed to retrieve removeGhost method

不羁岁月 提交于 2021-02-07 12:52:25
问题 I'm putting in place the Android Navigation Component in my app. Some transitions work fine, but for this one I have an error. The transition view, from fragment A, stay on the new fragment (B) and hide some elements. Moreover, when I scroll in the fragment, the view don't scroll with it. This is the error I get: W/t.qoqa.ui.debu: Accessing hidden method Landroid/view/GhostView;->removeGhost(Landroid/view/View;)V (greylist-max-p, reflection, denied) I/GhostViewApi21: Failed to retrieve

Android Navigation Component : Pass value (arguments) in fragments

佐手、 提交于 2021-02-07 11:27:23
问题 What I have done: I have created Navigation Drawer Activity , As updated new format of Navigation Drawer Activity , As per new Android architecture, I got it with Navigation Component structure. The NavigationView code with NavController and NavigationUI as below which is opening fragment when I click on any navigation item. DrawerLayout drawer = findViewById(R.id.drawer_layout); NavigationView navigationView = findViewById(R.id.nav_view); // Passing each menu ID as a set of Ids because each