gpt4 book ai didi

java - tabhost android 中的 Activity ?

转载 作者:行者123 更新时间:2023-11-30 04:27:00 25 4
gpt4 key购买 nike

我想在选项卡中进行不同的 Activity ,这是我编写的代码,但应用程序不断崩溃,这是怎么回事?

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);

如有任何帮助,我们将不胜感激

编辑

这是我在 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(本地方法)

最佳答案

您需要了解如何在 Eclipse 中调试以及如何使用 ADBDDMS工具。

为了获得有关异常/强制关闭的更多详细信息,您需要在 Eclipse 中查找名为 Logcat 的 View (您会在 DDMS 透视图中找到)在那里您会找到详细的追溯时间/内容以及问题所在。

为此,您应该阅读有关 Debugging in Android using Eclipse 的完整文章

alt text
(来源:droidnova.com)

关于java - tabhost android 中的 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8322250/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com