Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 解决
来源:互联网 发布:js date unix时间戳 编辑:程序博客网 时间:2024/04/30 07:33
问题1.
运行Activity的时候出现Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'
添加Layout的时候,xml跟元素选择TabHost, 但是ADT没有添加id属性, 运行的时候,会提示Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'错误, 需要添加android:id="@android:id/tabhost", 这样就可以了。
问题2.
运行Activity的时候出现Your TabHost must have a TabWidget whose id attribute is 'android.R.id.tabcontent'
解决方法: 修改FrameLayout添加id属性, ADT自动生成的xml文件中Id是android:id="@+id/FrameLayout01 ", 需要修改成下面的格式android:id="@android:id/tabcontent ",这个估计会困扰一大批初学者,谁会想到会修改这个地方,看到错误很容易修改成tabcontent,但是前缀不容易想到。 而且在ADT可视化编辑这个文件的时候, 界面上显示NullPointerException,这个是ADT的一个BUG。
修改后的xml如下:
<?xml version="1.0" encoding="utf-8"?>
<TabHost
android:id="@android:id/tabhost"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="@+id/LinearLayout01" android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical">
<TabWidget android:id="@android:id/tabs" android:layout_height="wrap_content" android:layout_width="fill_parent">
</TabWidget>
<FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent">
</FrameLayout>
</LinearLayout>
</TabHost>
注意: 如果用TabHost的话, 上面标红的三处必须是一样, 这个是Google的约定。 而且一个工程中只能有一个TabHost。
(3) 可以删除自己配置文件,不用指定配置文件。
特别注意:调换framelayout和tabwidget的前后顺序可以分别实现tab的top和在底下的效果。
- 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
- 一个操作系统的实现
- C++ Interview Question test-3 question-2
- AC自动机算法详解
- Android开发:Wifi基础
- JSON数据格式和js操作json总结
- Your content must have a TabHost whose id attribute is 'android.R.id.tabhost' 解决
- 手机免费上网时代已经到来
- objc系列译文(3.1):绘制像素到屏幕
- red hat下命令行乱码的解决方法
- ubuntu apache2下目录结构
- Android4.0内存Dex数据动态加载技术
- Android下通过Canvas类和Paint类画一个表格的方法
- 【iOS开发-5】storyboard还是苦逼摞代码?看看各家之言
- Oracle截取指定字符前的字符串