I am trying to make a Settings Activity using a PreferenceActivity. The problem is that the ActionBar won't show up no matter what I do.
I've tried getSupportActionBar, getActionBar, setActionBar. Nothing works.
I see other apps settings with ActionBars. Do they not use PreferenceActivity?
If you are using an AppCompat theme, you have to pay attention to some points.
The
PreferenceActivitydoesn't extend theAppCompatActivityor the deprecatedActionBarActivity.As solution you can create a
PreferenceFragmentas you are doing and use it in a standardAppCompatActivity. Of course you can use also aToolbar.Moreover with the new 22.1+ appcompat you can use the AppCompatDelegate to extend AppCompat's support to any Activity.
You can check this official link to AppCompatPreferenceActivity, where you can find an example of this technique.