Hi all,
I am trying to start activity to a TabActivity intent and I keep
getting the same error. I have tried to make this as simplistic as
possible code wise...but no luck. My code is below the error message.
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.valpak.android/com.valpak.android.TabLayout}:
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.valpak.android/com.valpak.android.Categories}:
java.lang.RuntimeException: Your content must have a TabHost whose id
attribute is 'android.R.id.tabhost'
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2401)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2417)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.ActivityThread.access$2100(ActivityThread.java:116)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.os.Handler.dispatchMessage(Handler.java:99)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.os.Looper.loop(Looper.java:123)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.ActivityThread.main(ActivityThread.java:4203)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
java.lang.reflect.Method.invokeNative(Native Method)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
java.lang.reflect.Method.invoke(Method.java:521)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
dalvik.system.NativeStart.main(Native Method)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): Caused by:
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.valpak.android/com.valpak.android.Categories}:
java.lang.RuntimeException: Your content must have a TabHost whose id
attribute is 'android.R.id.tabhost'
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2401)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.ActivityThread.startActivityNow(ActivityThread.java:2242)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.LocalActivityManager.moveToState(LocalActivityManager.java:
127)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.LocalActivityManager.startActivity
(LocalActivityManager.java:339)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.widget.TabHost$IntentContentStrategy.getContentView
(TabHost.java:631)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.widget.TabHost.setCurrentTab(TabHost.java:317)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.widget.TabHost.addTab(TabHost.java:210)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
com.valpak.android.TabLayout.onCreate(TabLayout.java:26)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2364)
11-03 12:57:52.114: ERROR/AndroidRuntime(10255): ... 11 more
This is called in MyApp.java
startActivity(new Intent(getApplicationContext(),
TabLayout.class));
public class TabLayout extends TabActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost tabHost = getTabHost();
LayoutInflater.from(this).inflate(R.layout.tabs,
tabHost.getTabContentView(), true);
tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("Grid").setContent(new Intent(this,
Categories.class)));
}
}
Here is tabs.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/tabLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
</LinearLayout>
Any help would be greatly appreciated.
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en