I have a problem to show HomeAsUp . I think there is such as a way to link NavColtroller with ActionBar. so I don't need to adjust Toolbar manually for each Fragment, mainly when use inclusive return to previous screen.
How to show HomeAsUp when use Android navigation graph
325 views Asked by Maher Abuthraa At
2
There are 2 answers
0
Hardik Bambhania
On
Below is working for me
layoyt.xml
<ConstraintLayout>
<Toolbar>
<fragment>
</ConstraintLayout>
Inside activity.java
private fun setUpToolbar() {
toolBar = findViewById(R.id.toolbar)
toolBar.inflateMenu(R.menu.menu)
setSupportActionBar(toolBar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
}
Related Questions in ANDROID
- Creating global Class holder
- Flutter + Dart: Editing name of a tab shows up a black screen
- android-pdf-viewer Received status code 401 from server: Unauthorized
- Sdk 34 WRITE_EXTERNAL_STORAGE not working
- ussd reader in Recket Native module
- Incorrect display of LinearGradientBrush in IOS
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- I can't make TextInput to auto expand properly in Android
- Creating multiple instances of a class with different initializing values in Flutter
- How to create a lottie animation
- making android analyze with coverity sast tool
- Flutter plugin development android src not opening after opening example
- I initialize my ViewModel in the Activity with several fragments as tabs, but the fragments(tabs) return null for the updated livedata
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How I can use the shared preferences class?
Related Questions in ANDROID-NAVIGATION
- How to force NavController#onGraphCreated to be called when calling setGraph twice with androidx.navigation 2.7.5
- Kotlin safe args direction is not generating
- How to correctly navigate to another fragment
- Why Edit text input fill all the other edit texts when navigate to other screen and then come back?
- App is crashing while trying to pass values from one screen to other
- Thoughts on this concept for a Jetpack Compose navigation library supporting nested NavHosts?
- Error when navigating from a DialogFragment in Android using the navGraph
- How to navigate to Android Dialog destination with cafe.adriel.voyager:voyager-navigator:1.0.0
- Android compose Modifer onKeyEvent for back pressed with voyager navigation library
- i have no app/build/generated/source/navigation-args folder
- How to retain a composable element on the screen while navigating between screens in Jetpack Compose
- onBackPressedDispatcher breaks Jetpack Compose Navigation
- setNavigationItemSelectedListener catches/blockes every menu item even if I return false
- Navigation related components are behaving differently
- Deep linking in Compose Single Activity Architecture
Related Questions in ANDROID-COMPONENTS
- Android Java: How to get component in a custom view? (Trying to access components via findByViewId and get null)
- Android Jetpack Compose Grid looking view
- is it necessary to unRegisterForActivityResult when start activity for result in android ? how manage different request codes?
- Android Work Manager periodic work request not repeating when app is cleared from recents
- While setting Minimum date for one year calendar is showing hidden date in the calendar header
- How to set toolbar title from fragment using Navigation UI Component
- Android Navigation - Hide action bar for loading/splash screen?
- Can I inspect any app's layout to find out which components they are using on Android device?
- Action is not generated in FragmentDirections when Fragment is used in a second nav graph
- Android - compare between button background to Resource
- BottomNavigationView background color with opacity not working properly
- Can I create a reusable component in an Android XML layout?
- Android Fragment isAdded returns false and getActivity is null after posting thread in the onResume method
- Is there a way to define the starting tab in the navigation advanced sample?
- Android Two Way Databinding working only one way
Related Questions in ANDROID-NAVIGATION-GRAPH
- How to correctly navigate to another fragment
- Restricting back navigation from nested nav graph
- Second level child fragment hides the parent fragment
- Automatic Argument Storage in SavedStateHandle by Navigation Component
- onBackPressedDispatcher breaks Jetpack Compose Navigation
- Navigation action/destination error in Kotlin
- Saving state of screen A when navigating from screen A to screen B and than back to screen A with Android Navigation
- Navigation with Jetpack Compose - navigagte to another graph
- DaggerHilt: Cannot create an instance of class ViewModel
- Android differentiate between navigate with argument and navigateUp
- How to define individual toolbar for different destination's on Naviagtion drawer with Navigation component
- How can i share data between navigation subgraph viewmodels in Android using Jetpack compose?
- How to fix java.lang.OutOfMemoryError in this case?
- Jetpack Compose nested navigation with shared route using wrong default args (addInDefaultArgs)
- How to do Sub Menu with Mutiple Level in Android Kotlin
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
I found the answer
After setup Toolbar add this command in activity:
Actually this is not enough .. because HomeAsUp will be visible but not working !
To make it work It's necessary to override this method :
Dont forget to have proper attributes in graph (popUpTo and popUpToInclusive):