Getting The Null Pointer Exception In The GetActionBar Method
Solution 1:
If you use Theme.AppCompat
, then extend ActionBarActivity
. Also use getSupportActionBar()
instead of getActionBar()
. You might also need to enable title (but I am not sure if thats true for all android versions) - so requestWindowFeature(Window.FEATURE_NO_TITLE);
should be removed - do you have in your theme:
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
by any chance.
Solution 2:
Did you extend ActionBarActivity?
public class MainActivity extends FragmentActivity implements ActionBar.TabListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final ActionBar actionBar = getActionBar();
actionBar.show();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
...
}
Solution 3:
Use a theme for your application that provides the AcionBar
, maybe you can include the appcompact
support library.
You can give a look at this post:
Solution 4:
Depends of your version (in Manifest) you need to use getSupportActionBar();
or getActionBar();
. Also are you sure what your homeActivy
are extending from an Activity.class
?
Solution 5:
Try to use the getSupportedActionBar-Method. I think you use another version of android
Post a Comment for "Getting The Null Pointer Exception In The GetActionBar Method"