android-navigation

Disabling the current tab in a bottom navigation controller

守給你的承諾、 提交于 2020-01-30 03:15:11
问题 I'm using Jetpack Navigation to handle the bottom navigation controller. It works great; however, I am looking for a way to improve the UX. Is it possible to disable the tab that the user is currently navigated to? I'm able to "spam" the current tab in the bottom navigation, which reloads data & the UI unnecessarily. If this behavior (of re-tapping the current tab) is intended, is there a way to retain the state of the fragment, so that when navigated away & to, it doesn't recreate? How I

Android Navigation Component back button not working

此生再无相见时 提交于 2020-01-25 06:39:09
问题 I'm using the Navigation Component in android where I have set 6 fragments initially. The problem is when I added a new fragment (ProfileFragment). When I navigate to this new fragment from the start destination, pressing the native back button does not pop the current fragment off. Instead, it just stays to the fragment I'm in - the back button does nothing. Here's my navigation.xml : <?xml version="1.0" encoding="utf-8"?> <navigation xmlns:android="http://schemas.android.com/apk/res/android

Espresso test Fail

China☆狼群 提交于 2020-01-24 19:31:09
问题 I am doing some Espresso testing in Android. The test is failing with this error: java.lang.ClassCastException: androidx.fragment.app.testing.FragmentScenario$EmptyFragmentActivity cannot be cast to com.stavro_xhardha.pockettreasure.MainActivity This is my test method: @Test fun toolbarTitle_shouldContainCorrectInput() { val mockNavController = mock(NavController::class.java) val fragmentScenario = launchFragmentInContainer<SetupFragment>() fragmentScenario.onFragment { Navigation

How do I change my button image with navigation drawer opening and closing

坚强是说给别人听的谎言 提交于 2020-01-23 02:56:10
问题 I have a navigation button for my navigation fragment which turns active and opens a navigation drawer menu upon click: Now when I click it, it turns active as follows: However, I want to associate it with a navigation drawer such a way that, even if I do not click the button and slide open the navigation drawer, the button turns active when the navigation drawer menu is open and when closed by sliding back in from right to left, the button turns red/inactive. The code which I am trying to

How to refresh list of the navigation drawer as soon as its open/closed in Android

蓝咒 提交于 2020-01-22 13:44:27
问题 I have created navigation drawer and displaying items in list. My list is static but i am displaying points. So when users select the items in the list and do some activity he get the points. So i want to update the points as soon as he gets. How can i do this./ Below is my code: Activity Class: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_page); // Initializing dataList = new ArrayList<DrawerItem>(); mTitle =

How to refresh list of the navigation drawer as soon as its open/closed in Android

浪尽此生 提交于 2020-01-22 13:44:11
问题 I have created navigation drawer and displaying items in list. My list is static but i am displaying points. So when users select the items in the list and do some activity he get the points. So i want to update the points as soon as he gets. How can i do this./ Below is my code: Activity Class: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_page); // Initializing dataList = new ArrayList<DrawerItem>(); mTitle =

How to refresh list of the navigation drawer as soon as its open/closed in Android

风流意气都作罢 提交于 2020-01-22 13:43:13
问题 I have created navigation drawer and displaying items in list. My list is static but i am displaying points. So when users select the items in the list and do some activity he get the points. So i want to update the points as soon as he gets. How can i do this./ Below is my code: Activity Class: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home_page); // Initializing dataList = new ArrayList<DrawerItem>(); mTitle =

New navigation component from arch with nested navigation graph

感情迁移 提交于 2020-01-22 04:14:27
问题 I have one case and wish to implement it by arch navigation component. For example I have 2 Nav Graphs (main and nested). Can I call main graph from nested and how? example 回答1: The point is to get the right NavController to navigate in the right graph. Let's take this scenario as an example: MainActivity |- MainNavHost |- NavBarFragment | |- NestedNavHost | | |-NestedContentFragment1 | | |-NestedContentFragment2 | | | |- BottomNavigationView | |- LoginFragment The main graph and the nested

How to change start destination of a navigation graph programmatically [Jetpack]

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-20 02:09:47
问题 Basically, I have the following navigation graph: I want to change my starting point in navigation graph to fragment 2 right after reaching it (in order to prevent going back to fragment 1 when pressing back button - like with the splash screen). This is my code: navGraph = navController.getGraph(); navGraph.setStartDestination(R.id.fragment2); navController.setGraph(navGraph); But, obviously it's not working and it gets back to fragment 1 after pressing back button. Am I doing it wrong? Is

how to remove default animation transition when using navigation component in Android?

安稳与你 提交于 2020-01-15 09:14:36
问题 I am using Navigation component, and I have a bottom navigation view in the main activity. when I tap the tab in that bottom navigation view, it seems that there is a fade in animation when the fragment appear. I don't think I manually set the animation, it seems that the animation will be there by default. I want to remove that animation. here is the code I use in my Main Activity. class MainActivity : AppCompatActivity(), NavController.OnDestinationChangedListener { private lateinit var