In many apps (Calendar, Drive, Play Store) when you tap a button and enter a new activity, the icon in the title bar turns into a back button, but for the app I am making, i
Just sharing something that helped me and may be useful for others. Although most of the answers here are correct, by using the getActionBar().setDisplayHomeAsUpEnabled(true);
, this wasn't working for me. The issue I had was that I was trying to create a second Activity manually, but there are more details involved.
What really solved my problem was following Android Developers tutorial (https://developer.android.com/training/basics/firstapp/starting-activity) for creating a second Activity using Android Studio own tools:
Create the second activity
1. In the Project window, right-click the app folder and select New > Activity > Empty Activity.
2. In the Configure Activity window, enter "DisplayMessageActivity" for Activity Name and click Finish (leave all other properties set to the defaults).
Android Studio automatically does three things:
- Creates the DisplayMessageActivity file.
- Creates the corresponding activity_display_message.xml layout file.
- Adds the required element in AndroidManifest.xml.