Questions tagged [android-navigation]

For questions about navigation within and between Android apps. Examples include navigating between activities/fragments, up/back behavior, task stacks, and Intent flags that affect navigation behavior.

Consistent navigation is an essential component of the overall user experience. Few things frustrate users more than basic navigation that behaves in inconsistent and unexpected ways.

Android 3.0 introduced significant changes to the global navigation behavior. Thoughtfully following the guidelines for Back and Up will make your app's navigation predictable and reliable for your users.

Android 2.3 and earlier relied upon the system Back button for supporting navigation within an app. With the introduction of action bars in Android 3.0, a second navigation mechanism appeared: the Up button, consisting of the app icon and a left-point caret.

See also the official documentation about this topic.

1192 questions
8
votes
6 answers

Android Navigation view: Scroll the menu items only issue

I want to scroll only the menu items of the navigation view but it also scroll the header with it. Please any body tell me how to achieve this... Here is my code: activity_main.xml
8
votes
3 answers

Swapable tabs in Slider Menu fragment

I have implemented Navigation Drawer by Referring this tutorial and now what I want to do is to display swiping tabs inside a fragment. i.e. when i click on an item in navigation drawer, lets say the first one, it should display swiping tabs for…
8
votes
2 answers

Android Navigation Drawer implemented with Activities

I am developing my own Android Application and i came to a point where i have three different Activities say Activity A, Activity B and Activity C. What i want to do now is to create a Navigation Drawer to navigate between them. I read the tutorial…
7
votes
3 answers

How to clear activity history stack when pressing home button?

I'm writing an application which have two "modes"; one view mode and one edit mode. The application exposes two main/launcher activities (say, A and D) which in turn have their own activity chains (B, C and E, F respectively). The two entry point…
dbm
  • 10,376
  • 6
  • 44
  • 56
7
votes
4 answers

Navigation with View Binding

I'm trying to replace all findViewById using View Binding. But, I can't change my NavController code line using View Binding. val navController = findNavController(this, R.id.mainHostFragment) to var binding : ActivityMainBinding val navController…
Thaw De Zin
  • 1,409
  • 2
  • 10
  • 18
7
votes
1 answer

Fragment tag names with NavController navigate

When using the navigation architecture, is it possible to explicitly assign fragment tag names to the fragments that you navigate to so that later you can refer back to them if you need to do something with them on the back stack? I'm referring to…
7
votes
1 answer

Navigation Components - onSupportNavigateUp()

Is it really necessary to call override fun onSupportNavigateUp() = findNavController(R.id.nav_host_fragment).navigateUp() in my MainActivity ? Because when I attach the NavHostFragment in my xml it starts from there, but I have seen the Google I/O…
7
votes
2 answers

Android Navigation Architecture not navigating when phone screen is OFF

I have the following architecture in my project: MainActivity layout:
7
votes
1 answer

NavHostFragment not resolved (AndroidX)

For some reason I always get confronted with the following error: Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment androidx.navigation.fragment.NavHostFragment: make sure class name exists, is public, and…
7
votes
2 answers

GnssStatus.CallBack onSatelliteStatusChanged() not working

I am developing an application that I want to learn about the count of gps satellites. I am using the "onSatelliteStatusChanged" method for this, but it does not work. The piece of code that I use below that you see. Code if (Build.VERSION.SDK_INT…
7
votes
2 answers

Go back to Activity without recreating (without invoking onCreate())

I would like to ask similar question to: Go back to previous screen without creating new instance However I don't want Activity A go through onCreate callback, I would like to return to previous instance in the same state. How to achieve that…
Adam Styrc
  • 1,517
  • 2
  • 23
  • 38
7
votes
2 answers

Android Material Design Navigation View -> Item

Can any one just tell me how to add a toggle button to android material design navigation view? Items are added from menu items drawer_menu_items.xml
asad.qazi
  • 2,449
  • 3
  • 23
  • 35
7
votes
2 answers

NavigationDrawer fragment with ListView and custom Header

I'm having a problem and I can not solve it. In my app I have a navigation drawer defined as…
7
votes
2 answers

Navigation Drawer disable backview when drawer open

I am getting a strage behaviour with my navigation drawer. I use a custom layout for it, containing not only the usual listview! Whenever i click somehwere in the drawer section the rows from the behind listview are getting clicked. How can i…
Adrian Olar
  • 2,883
  • 4
  • 35
  • 63
7
votes
2 answers

NavigationDrawer activity is cluttered with fragment callbacks and application business logic

An Activity containing NavigationDrawer is supposed to juggle its fragments. My problem is that the drawer has to be available on all possible screens of the application, which makes my only activity MainActivity very cluttered with…