i followed this tutorial implement tab layout android application. have existing android app i'm deeloping had adjust tutorial bit. i'm pretty sure did i'm supposed everytime click button that's supposed open tab layout activity, app crashes.
main tablayout activity:
public class bifrosttabs extends tabactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_bifrosttabs); tabhost tabhost = gettabhost(); //crafting tab tabspec crafttabspec = tabhost.newtabspec("crafting"); crafttabspec.setindicator("crafting", getresources().getdrawable(r.drawable.weaponsmith_logo)); intent craftintent = new intent(this, bifrost.class); crafttabspec.setcontent(craftintent); //addition info tab tabspec infotabspec = tabhost.newtabspec("info"); infotabspec.setindicator("info", getresources().getdrawable(r.drawable.craft_info)); intent infointent = new intent(this, bifrostinfo.class); infotabspec.setcontent(infointent); tabhost.addtab(crafttabspec); tabhost.addtab(infotabspec); }
main tablayout activity xml file:
<tabhost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <tabwidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <framelayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </linearlayout>
button method opens tab layout activity:
public void onclick (view v){ switch (v.getid()){ case r.id.button1: intent bifrost = new intent (mainactivity.this, bifrosttabs.class); startactivity(bifrost); break; ...rest of code other buttons
whole logcat file:
07-15 17:57:00.084: e/jdwp(14846): failed writing handshake bytes: broken pipe (-1 of 14) 07-15 17:57:06.186: e/androidruntime(14846): fatal exception: main 07-15 17:57:06.186: e/androidruntime(14846): java.lang.runtimeexception: unable start activity componentinfo{com.matthewstudios.gw2legendary/com.example.gw2legendary.tablayouts.bifrosttabs}: java.lang.runtimeexception: unable start activity componentinfo{com.matthewstudios.gw2legendary/com.example.gw2legendary.craftingactivities.bifrost}: java.lang.nullpointerexception 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activitythread.performlaunchactivity(activitythread.java:2180) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2230) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activitythread.access$600(activitythread.java:141) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activitythread$h.handlemessage(activitythread.java:1234) 07-15 17:57:06.186: e/androidruntime(14846): @ android.os.handler.dispatchmessage(handler.java:99) 07-15 17:57:06.186: e/androidruntime(14846): @ android.os.looper.loop(looper.java:137) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activitythread.main(activitythread.java:5041) 07-15 17:57:06.186: e/androidruntime(14846): @ java.lang.reflect.method.invokenative(native method) 07-15 17:57:06.186: e/androidruntime(14846): @ java.lang.reflect.method.invoke(method.java:511) 07-15 17:57:06.186: e/androidruntime(14846): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 07-15 17:57:06.186: e/androidruntime(14846): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 07-15 17:57:06.186: e/androidruntime(14846): @ dalvik.system.nativestart.main(native method) 07-15 17:57:06.186: e/androidruntime(14846): caused by: java.lang.runtimeexception: unable start activity componentinfo{com.matthewstudios.gw2legendary/com.example.gw2legendary.craftingactivities.bifrost}: java.lang.nullpointerexception 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activitythread.performlaunchactivity(activitythread.java:2180) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activitythread.startactivitynow(activitythread.java:2023) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.localactivitymanager.movetostate(localactivitymanager.java:135) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.localactivitymanager.startactivity(localactivitymanager.java:347) 07-15 17:57:06.186: e/androidruntime(14846): @ android.widget.tabhost$intentcontentstrategy.getcontentview(tabhost.java:749) 07-15 17:57:06.186: e/androidruntime(14846): @ android.widget.tabhost.setcurrenttab(tabhost.java:413) 07-15 17:57:06.186: e/androidruntime(14846): @ android.widget.tabhost.addtab(tabhost.java:240) 07-15 17:57:06.186: e/androidruntime(14846): @ com.example.gw2legendary.tablayouts.bifrosttabs.oncreate(bifrosttabs.java:34) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activity.performcreate(activity.java:5104) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activitythread.performlaunchactivity(activitythread.java:2144) 07-15 17:57:06.186: e/androidruntime(14846): ... 11 more 07-15 17:57:06.186: e/androidruntime(14846): caused by: java.lang.nullpointerexception 07-15 17:57:06.186: e/androidruntime(14846): @ com.example.gw2legendary.craftingactivities.bifrost.oncreate(bifrost.java:160) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activity.performcreate(activity.java:5104) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 07-15 17:57:06.186: e/androidruntime(14846): @ android.app.activitythread.performlaunchactivity(activitythread.java:2144) 07-15 17:57:06.186: e/androidruntime(14846): ... 21 more 07-15 17:57:14.967: e/fb4a(:<default>):mmsconfig(14952): mmsconfig.loadmmssettings mms_config.xml missing uaprofurl setting
i'm pretty sure gave important code there give. if forgot please let me know.
thanks this user, figured out! there wrong line 160 in class bifrost.
actionbar actionbar = getactionbar(); actionbar.setdisplayhomeasupenabled(true);
these 2 lines caused trouble! guess can't enable action bar if have tab layout.
Comments
Post a Comment