From the course: Android Development Essential Training: Manage Data with Kotlin
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Add an Up button to a secondary fragment
From the course: Android Development Essential Training: Manage Data with Kotlin
Add an Up button to a secondary fragment
- In my application's current state, I can select a data item from the RecyclerView and that takes me to the detail fragment. Now I want to add a navigation user interface element, an up button that the user can press to return back to the main fragment. I'll start in the detail fragment class. And first I want to do a little code reorganization. When I first created my application, all the files relating to my main fragment were placed in a single package. I want to continue to follow that pattern. So I'll go to my base package and I'll create a new package under that, and I'll call it ui.detail. Then, I'll drag my detail fragment class into the new detail package. So everything having to do with the detail fragment is here and everything having to do with the main fragment is here. Next, I'm ready to display an up button. I'll do that work here in the detail fragment class in the onCreateView function. I'm going to call function called setDisplayHomeAsUpEnabled and pass in a value…
Contents
-
-
-
-
-
-
(Locked)
Handle RecyclerView click events4m 7s
-
Create and navigate to a detail fragment4m 14s
-
(Locked)
Add an Up button to a secondary fragment4m 47s
-
(Locked)
Pass data in a shared ViewModel5m 10s
-
(Locked)
Display details with data binding6m 15s
-
(Locked)
Customize data bindings with an adapter5m 14s
-
(Locked)
-
-
-
-