From the course: Android Development Essential Training: App Architecture with Kotlin

Unlock the full course today

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

Finish an activity with an up button

Finish an activity with an up button - Android Tutorial

From the course: Android Development Essential Training: App Architecture with Kotlin

Start my 1-month free trial

Finish an activity with an up button

- [Instructor] The more visual prompts a user has, the more successful they'll be using your app. It's common to display a button at the top corner of a secondary activity that the user can press to return to the activity's parent. And it takes just a single line of code to display a default image, an arrow pointing to the edge that when pressed will return to the parent activity. I'm in the dice activity class and I'll add this code after the call to set support action bar. I'll start with a reference to the action bar object, support action bar question mark because it's a nullible object and then I'll call this function with the very long name. Set display home as up enabled, and I'll pass in a boolean value of true. And now when I run the application and I press the rolling button to go to the secondary activity, I see the up button. It's actually an arrow pointing to the side. And when I press it, I go back to the parent activity. If you want to use a different graphic, you can…

Contents