错误处理:your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
来源:互联网 发布:sql server 聚合 编辑:程序博客网 时间:2024/05/17 08:09
activity_main.xml如下
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#EEEEEE" android:orientation="vertical" > <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#EEEEEE" > <TextView android:id="@+id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1.0" android:gravity="center" android:text="标题1" android:textColor="#000000" android:textSize="18.0dip" /> <TextView android:id="@+id/text2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0" android:gravity="center" android:text="标题2" android:textColor="#000000" android:textSize="18.0dip" /> <TextView android:id="@+id/text3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1.0" android:gravity="center" android:text="标题3" android:textColor="#000000" android:textSize="18.0dip" /> </LinearLayout> <ImageView android:id="@+id/cursor" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#EEEEEE" android:scaleType="matrix" android:src="@drawable/offine" /></LinearLayout>
MainActivity.java如下:
public class MainActivity extends TabActivity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);}}
调试时,始终报如下错误:
04-30 09:38:17.309: E/AndroidRuntime(17324): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gocom.traincheck/com.gocom.traincheck.activity.MainActivity}: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
经多次尝试,问题找到,原因是MainActivity.java继承了TabActivity,因此在activity_main.xml中必须有类似以下的定义:
<TabHost android:id="@android:id/tabhost"
.....
1 1
- 错误处理:your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
- 错误处理:your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
- Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 解决
- Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 解决
- Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 解决
- Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 解决
- Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 解决
- Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 解决
- Android: Your content must have a TabHost whose id attribute is ‘android.R.id.tabhost’ 错误分析及解决方法
- java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.ta
- [BUG]Your TabHost must have a TabWidget whose id attribute is ‘android.R.id.tabcontent’
- 5 Your TabHost must have a TabWidget whose id attribute is 'android.R.id.tabs'
- 5 Your TabHost must have a TabWidget whose id attribute is ‘android.R.id.tabcontent’
- [ERROR]Your TabHost must have a TabWidget whose id attribute is 'android.R.id.tabcontent'
- Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 问题,写了id语句仍出错的解决办法
- java.lang.RuntimeException: Your content must havea TabHost whose id attribute is‘android.R.id.tabhost’
- Your content must have a ListView whose id attribute is 'android.R.id.list'
- Your content must have a ListView whose id attribute is 'android.R.id.list'解决办法。
- 关于内核模块挂载出现“no symbol version for”问题的研究
- 关于JSP和HTML
- iOS开发者协会 iOS开发常用的第三方类库
- JSP中的page,request,session,application
- cpu 多核/多cpu
- 错误处理:your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
- 20140430
- Java线程 - 四种线程池的使用
- zendFrameWork的工作目录
- 寻址空间
- 金山——弱智的翻译程序
- photoshop支持的常用图片格式及其介绍
- ffmpeg 源代码简单分析 : avcodec_register_all()
- HTML中Readonly和Disabled的区别