getSupportActionBar returns null in android 4.1 and above -


getsupportactionbar returns null in android 4.1 , above. using support v4 , sherlockfragmentactivity.

this logcat.

03-10 11:35:47.876: e/crittercism(4778): java.lang.runtimeexception: unable start activity componentinfo{com.cx.android/com.cx.android.ui.homeactivity}: java.lang.nullpointerexception 03-10 11:35:47.876: e/crittercism(4778):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2245) 03-10 11:35:47.876: e/crittercism(4778):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:2299) 03-10 11:35:47.876: e/crittercism(4778):    @ android.app.activitythread.access$700(activitythread.java:150) 03-10 11:35:47.876: e/crittercism(4778):    @ android.app.activitythread$h.handlemessage(activitythread.java:1280) 03-10 11:35:47.876: e/crittercism(4778):    @ android.os.handler.dispatchmessage(handler.java:99) 03-10 11:35:47.876: e/crittercism(4778):    @ android.os.looper.loop(looper.java:137) 03-10 11:35:47.876: e/crittercism(4778):    @ android.app.activitythread.main(activitythread.java:5283) 03-10 11:35:47.876: e/crittercism(4778):    @ java.lang.reflect.method.invokenative(native method) 03-10 11:35:47.876: e/crittercism(4778):    @ java.lang.reflect.method.invoke(method.java:511) 03-10 11:35:47.876: e/crittercism(4778):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1102) 03-10 11:35:47.876: e/crittercism(4778):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:869) 03-10 11:35:47.876: e/crittercism(4778):    @ dalvik.system.nativestart.main(native method) 03-10 11:35:47.876: e/crittercism(4778): caused by: java.lang.nullpointerexception 03-10 11:35:47.876: e/crittercism(4778):    @ com.cx.android.ui.homeactivity.oncreate(homeactivity.java:71) 03-10 11:35:47.876: e/crittercism(4778):    @ android.app.activity.performcreate(activity.java:5283) 03-10 11:35:47.876: e/crittercism(4778):    @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1097) 03-10 11:35:47.876: e/crittercism(4778):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2209) 03-10 11:35:47.876: e/crittercism(4778):    ... 11 more 

this edit. class returns npe.

public class homeactivity extends sherlockfragmentactivity implements onnavigationlistener {     public static final string tag = "homeactivity";      private homedropdownlistadapter homeadapter;     private fragmentmanager fragmentmanager;     private dashboardfragment dashboard;      private actionbar actionbar;       private static homeactivity staticinstance;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.view_main);          staticinstance = this;         fragmentmanager = getsupportfragmentmanager();         navstack = new stack<long>();          // action bar         actionbar = homeactivity.this.getsupportactionbar();         actionbar.setdisplayshowhomeenabled(false);         //actionbar.setdisplayoptions(10);         actionbar.setdisplayshowtitleenabled(false);         actionbar.setnavigationmode(actionbar.navigation_mode_list);         homeadapter = new homedropdownlistadapter(this);         actionbar.setlistnavigationcallbacks(homeadapter, this);         actionbar.setselectednavigationitem(app.starting_nav_index); 

edit 2: added manifest theme: called application tag's theme:

<style name="theme.maintheme" parent="@style/theme.sherlock">     <item name="actionbarstyle">@style/widget.styled.actionbar</item>     <item name="android:actionbarstyle">@style/widget.styled.actionbar</item>     <item name="android:windowbackground">@color/background</item>     <item name="actionbarsize">54dp</item>     <item name="android:actionbarsize">54dp</item> </style>  <style name="widget.styled.actionbar" parent="widget.sherlock.actionbar.solid">     <item name="background">@drawable/actionbar_background</item>     <item name="android:background">@drawable/actionbar_background</item> </style>  <style name="theme.dialog" parent="@android:style/theme.dialog">     <item name ="android:windowactionbar">false</item> </style> 


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -