我一直在尝试将三种不同的活动分别添加到不同的标签中...... 一项活动是启动蓝牙发现和选择蓝牙设备进行配对
第二个将是基于蓝牙的鼠标垫
我正在关注许多在线资料..基本上这一个http://www.androidhive.info/2011/08/android-tab-layout-tutorial/
但不知怎的,它显示了这个错误
11-08 13:41:24.673: D/AndroidRuntime(22886): Shutting down VM
11-08 13:41:24.673: W/dalvikvm(22886): threadid=1: thread exiting with uncaught exception (group=0x40ab6228)
11-08 13:41:24.714: E/AndroidRuntime(22886): FATAL EXCEPTION: main
11-08 13:41:24.714: E/AndroidRuntime(22886): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kant.BluetoothTest2/com.kant.BluetoothTest2.TabControllerActivity}: java.lang.RuntimeException: Your TabHost must have a FrameLayout whose id attribute is 'android.R.id.tabcontent'
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2194)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.ActivityThread.access$600(ActivityThread.java:139)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.os.Handler.dispatchMessage(Handler.java:99)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.os.Looper.loop(Looper.java:154)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.ActivityThread.main(ActivityThread.java:4945)
11-08 13:41:24.714: E/AndroidRuntime(22886): at java.lang.reflect.Method.invokeNative(Native Method)
11-08 13:41:24.714: E/AndroidRuntime(22886): at java.lang.reflect.Method.invoke(Method.java:511)
11-08 13:41:24.714: E/AndroidRuntime(22886): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-08 13:41:24.714: E/AndroidRuntime(22886): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-08 13:41:24.714: E/AndroidRuntime(22886): at dalvik.system.NativeStart.main(Native Method)
11-08 13:41:24.714: E/AndroidRuntime(22886): Caused by: java.lang.RuntimeException: Your TabHost must have a FrameLayout whose id attribute is 'android.R.id.tabcontent'
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.widget.TabHost.setup(TabHost.java:163)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.widget.TabHost.setup(TabHost.java:182)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.TabActivity.onContentChanged(TabActivity.java:135)
11-08 13:41:24.714: E/AndroidRuntime(22886): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:281)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.Activity.setContentView(Activity.java:1885)
11-08 13:41:24.714: E/AndroidRuntime(22886): at com.kant.BluetoothTest2.TabControllerActivity.onCreate(TabControllerActivity.java:16)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.Activity.performCreate(Activity.java:4531)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071)
11-08 13:41:24.714: E/AndroidRuntime(22886): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2150)
11-08 13:41:24.714: E/AndroidRuntime(22886): ... 11 more
帮助将不胜感激
答案 0 :(得分:1)
正如它在这里所说:
11-08 13:41:24.714:E / AndroidRuntime(22886):引起:java.lang.RuntimeException:你的TabHost必须有一个FrameLayout,其id属性是'android.R.id.tabcontent'
您缺少具有正确ID的frameLayout,因此请查看我的代码并尝试执行相同操作。希望它有所帮助:)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rootview"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TabHost
android:id="@+id/mainTabHost"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include layout="@layout/view_offer_tab1" />
<include layout="@layout/view_offer_tab2" />
</FrameLayout>
</LinearLayout>
</TabHost>