我想要標籤中的不同活動這裏是我寫的代碼,但應用程序不斷崩潰這裏發生了什麼?在tabhost android中的活動?
TabHost th = (TabHost)findViewById(R.id.tabhost);
th.setup();
TabSpec specs1 = th.newTabSpec("tag2");
specs1.setIndicator("Tab 2");
specs1.setContent(new Intent(this, Songs.class));
th.addTab(specs1);
任何幫助,將appritated感謝ü
編輯
這是我得到的logcat
11-29 23:23:06.490: D/AndroidRuntime(299): Shutting down VM
11-29 23:23:06.490: W/dalvikvm(299): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-29 23:23:06.510: E/AndroidRuntime(299): FATAL EXCEPTION: main
11-29 23:23:06.510: E/AndroidRuntime(299): java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?
11-29 23:23:06.510: E/AndroidRuntime(299): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:649)
11-29 23:23:06.510: E/AndroidRuntime(299): at android.widget.TabHost.setCurrentTab(TabHost.java:323)
11-29 23:23:06.510: E/AndroidRuntime(299): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:129)
11-29 23:23:06.510: E/AndroidRuntime(299): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:453)
11-29 23:23:06.510: E/AndroidRuntime(299): at android.view.View.performClick(View.java:2408)
11-29 23:23:06.510: E/AndroidRuntime(299): at android.view.View$PerformClick.run(View.java:8816)
11-29 23:23:06.510: E/AndroidRuntime(299): at android.os.Handler.handleCallback(Handler.java:587)
11-29 23:23:06.510: E/AndroidRuntime(299): at android.os.Handler.dispatchMessage(Handler.java:92)
11-29 23:23:06.510: E/AndroidRuntime(299): at android.os.Looper.loop(Looper.java:123)
11-29 23:23:06.510: E/AndroidRuntime(299): at android.app.ActivityThread.main(ActivityThread.java:4627)
11-29 23:23:06.510: E/AndroidRuntime(299): at java.lang.reflect.Method.invokeNative(Native Method)
11-29 23:23:06.510: E/AndroidRuntime(299): at java.lang.reflect.Method.invoke(Method.java:521)
11-29 23:23:06.510: E/AndroidRuntime(299): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-29 23:23:06.510: E/AndroidRuntime(299): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-29 23:23:06.510:E/AndroidRuntime( 299):在dalvik.system.NativeStart.main(本地方法)
發表您的logcat.and確保您延長TabActivity並不僅僅是活動! – Hiral
你有沒有在清單文件中註冊Activity? –
我想你必須使用TabHost th = getTabHost(); – Newts