Some other overridden methods

Almost certainly, you will have noticed that there are two other auto-generated methods in the code of all our projects using the Basic Activity template. They are onCreateOptionsMenu and onOptionsItemSelected. Most Android apps have a pop up menu, so Android Studio generates one by default, including the basic code to make it work.

You can see the XML that describes the menu in res/menu/menu_main.xml from the project explorer. The key line of XML code is this:

<item
      android:id="@+id/action_settings"
      android:orderInCategory="100"
      android:title="@string/action_settings"
      app:showAsAction="never" />

This describes a menu item with the text Settings. If you run any of the apps built with the Basic Activity template we have ...

Get Android Programming for Beginners - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.