i want to work with action bar in android. for this i use
getActionBar().setHomeButtonEnabled(true);
below the SetContentView . but is gives me null pointer exception. when i try only getActionBar() it works fine.
please help me.
i want to work with action bar in android. for this i use
getActionBar().setHomeButtonEnabled(true);
below the SetContentView . but is gives me null pointer exception. when i try only getActionBar() it works fine.
please help me.
getActionBar() will return null for pre Honeycomb devices.
If you are targeting Android v2.3 to 4.2 try out ActionBarSherlock.
If your activity does not have a
title bar
the methodgetActionBar()
can return null.You have two options to fix this:
1- Add
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
beforesetContentView
2- In your
Manifest
specify a Theme that supportsActionBar
Also make sure that you are targeting the right android version e.g.
<uses-sdk android:minSdkVersion="11" />