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.
If your activity does not have a title bar
the method getActionBar()
can return null.
You have two options to fix this:
1- Add getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
before setContentView
2- In your Manifest
specify a Theme that supports ActionBar
Also make sure that you are targeting the right android version e.g. <uses-sdk android:minSdkVersion="11" />
getActionBar() will return null for pre Honeycomb devices.
If you are targeting Android v2.3 to 4.2 try out ActionBarSherlock.