I searched a lot for this issue, but didn\'t found nothing relevant.
I\' updated my app project to use api 21, now when i run preferenceactivity i ge
Using a PreferenceActivcity
and the Theme.AppCompat.Light
the method getActionBar()
returns null.
You should use a different style (only for API>=11).
There is an alternative (a better alternative).
It is suggested in the official Google doc:
How do I use AppCompat with Preferences? You can continue to use PreferenceFragment in your ActionBarActivity when running on an API v11+ device. For devices before that, you will need to provide a normal PreferenceActivity which is not material-styled.
Then you can use a PreferenceFragment
and a ActionBarActivity
for api>11.
In this way you can use the Theme.AppCompat.Light theme.
Pay attention to use getSupportActionBar()
instead of getActionBar()
.