Android app dev: Add ActionBar to Preference Activity

When I converted an activity into PreferenceActivity, I noticed that its ActionBar disappeared. I’ll show you how I brought the ActionBar back to my PreferenceActivity.

In this guide I will assume that the name of the file that contains your is SettingsActivity.java, and that the view assigned to your SettingsActivity.java is named .

First, create settings_toolbar.xml under /app/src/main/res/layout/ and place the following code into it:

Then add the following overridden method to SettingsActivity.java:

The Java method programmatically creates a Toolbar object from the XML toolbar at settings_toolbar.xml.

Reference(s): Creating a Preference Screen with support (v21) Toolbar

Related Posts:

Posts that may be related to "Android app dev: Add ActionBar to Preference Activity":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *