Tushar Chutani
Tushar Chutani

Reputation: 1560

Activity in tabhost android?

I wanted diffrent activities in tabs here is the code I have written but the application is constantly crashing what is going on here?

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

any help would be appritated thank u

EDIT

this is what I get in 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): at dalvik.system.NativeStart.main(Native Method)

Upvotes: 1

Views: 390

Answers (1)

Pentium10
Pentium10

Reputation: 207912

You need to learn how to Debug in Eclipse and how to use the ADB and DDMS tools.

In order to get more details about an exception/force close you need to look for a view in Eclipse called Logcat(you will find in the DDMS perspective) there you will find a detailed traceback when/what and on what line is the issue.

For this you should read a complete article about Debugging in Android using Eclipse

alt text
(source: droidnova.com)

Upvotes: 1

Related Questions