From the course: Building an Android App with Jetpack Libraries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Navigate up to a previous destination

Navigate up to a previous destination - Android Tutorial

From the course: Building an Android App with Jetpack Libraries

Start my 1-month free trial

Navigate up to a previous destination

- [Instructor] Right now the user can return from the editor fragment to the main fragment. with the device's back button or gesture. But it's a good idea to add a user interface element to the app itself, for this operation. First I'll display a checkmark as an up button in the editor fragment. I'll add code here in the onCreateView function. And I'll start by getting a reference to the activity that owns this fragment. And I need to use the AppCompatActivity API. So I'll cast it that way. And then from there, I'll get a reference to the supportActionBar. Now that could return a no value. So I'll add a question Mark there. And then from there, I'll call let, and this is a Lambda expression, and all of this code will be executed. If the supportActionBar is not known. First I'll enable the home button with this function, I'll pass in true for that. Then I'll call it.setDisplayShowHomeEnabled. And again I'll pass in…

Contents