I get actionBar object below as null, and hence a NullPointerException when executing actionBar.setDisplayHomeAsUpEnabled(true). Following is my code which is called from onResume of the Fragment.
ActionBar actionBar = getActivity().getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
Followwing is the theme I apply to the activity in the onCreate:
<style name="MyActionBarTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>
<item name="actionMenuTextColor">@color/green</item>
<item name="colorPrimary">@color/green</item>
<item name="colorPrimaryDark">@color/greenD</item>
</style>
My application has minimum api level set to 14.
Please help me, explain why is the ActionBar object returned as null.
EDIT:
getActivity().getActionBar(); returns null in Fragment.