R.id.tabcontent报错的一些问题

来源:互联网 发布:数据库的物理结构 编辑:程序博客网 时间:2024/06/05 23:42

对项目做一些简单的框架搭建仍然是用的以前自己写的布局框架。在使用AndroidStudio的时候发现
android.support.v4.app.FragmentTabHost这个方法除了一些问题。如下:

    <?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:orientation="vertical" >          <FrameLayout              android:id="@+id/realtabcontent"              android:layout_width="match_parent"              android:layout_height="0dip"              android:layout_weight="1" />          <android.support.v4.app.FragmentTabHost              android:id="@android:id/tabhost"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:background="@drawable/bottom_bg" >              <TabWidget                  android:id="@android:id/tabs"                  android:layout_width="match_parent"                  android:layout_height="wrap_content"                  android:background="#000000"                  android:orientation="horizontal" />          </android.support.v4.app.FragmentTabHost>      </LinearLayout>  

之后在网上找到了一篇博客,问题解决:http://blog.csdn.net/deng0zhaotai/article/details/48295285

这边文章真心难找,在百度的搜索方式不一样,一般是搜索R.id.tabcontent的错误日志,这里是
“fragmenttabhost在新版v4包中”才能搜到这篇文章,我一开始也没想到是新V4包的版本问题,
因为androidstudio是最新下载的,创建项目的时候V4包自动使用最新的,所以我以前使用的V4
包是没这个bug的,而新版中暴露了出来,尝试使用了最新的android.support.design.widget.TabLayout,发现有Bug,当标签栏在底部时,系统会先加载内容页,
而不加载标签页,网上说开一个线程来手动加载标签页,我试了一下还是不行。。。如果有人成功了
麻烦告诉我方法,非常感谢!
这里对上述引用的博客再做一些补充。
博客所说的最后一个代码片段描述如下:

    <?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:orientation="vertical" >          <FrameLayout              android:id="@+id/realtabcontent"              android:layout_width="match_parent"              android:layout_height="0dip"              android:layout_weight="1" />          <android.support.v4.app.FragmentTabHost              android:id="@android:id/tabhost"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:background="@drawable/bottom_bg" >          </android.support.v4.app.FragmentTabHost>      </LinearLayout>  

遮挡的问题,在

<android.support.v4.app.FragmentTabHost ><<android.support.v4.app.FragmentTabHost />

这段代码中少了TabWidget这个控件,添加进去之后,按照其所说自定义了framelayout的id
代码中进行相应的更改,可仍然是不行的,提示“R.id.content XXXXXX”错误,我这里直接用的
倒数第二个代码段:

    <?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:orientation="vertical" >          <android.support.v4.app.FragmentTabHost              android:id="@android:id/tabhost"              android:layout_width="match_parent"              android:layout_height="wrap_content" >              <FrameLayout                  android:id="@android:id/tabcontent"                  android:layout_width="match_parent"                  android:layout_height="match_parent" />              <TabWidget                  android:id="@android:id/tabs"                  android:layout_width="match_parent"                  android:layout_height="wrap_content"                  android:layout_alignParentBottom="true"                  android:layout_gravity="bottom"                  android:background="#B0C4DE"                  android:orientation="horizontal"                  android:showDividers="middle" />          </android.support.v4.app.FragmentTabHost>      </LinearLayout>  

关于这个布局会导致覆盖掉TabWidget控件的问题,我这里在TabWidget所包含既一个标签布局中,
使用了warpcontent,然后将TabWidget控件修改:android:layout_height=”40dp”。一般底部标签
不会有多大,所以这里直接定义了一个比较高的dp值,一般是没什么问题的。如果有完美解决覆盖
问题的请告诉我,谢谢~

1 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 奖虫账号和密码不匹配怎么办 开淘宝店余额宝里的钱怎么办 京东找不到所有宝贝的链接了怎么办 淘宝店链接改了标题没流量怎么办 淘宝手淘搜索自然流量少怎么办 4个月宝贝不食欲下降怎么办 淘宝商家预售时间到了不发货怎么办 淘宝修改类目被处置管控了怎么办 淘宝换手机号是已经注册了的怎么办 闲鱼违规把我淘宝店铺冻结了怎么办 开网店店主想买自己的东西怎么办 以前用微博登录头条的账号怎么办 公众号注册提示邮箱已被占用怎么办 学信网注册时出现邮箱被占用怎么办 手机淘宝店铺接不到买家消息怎么办 买了东西淘宝店铺没了怎么办 淘宝店铺直播间虚假交易违规怎么办 手机淘宝退款物流单号填错了怎么办 淘宝评价删除了卖家没有返现怎么办 想摆摊卖麻辣烫不知怎么摆怎么办 在淘宝卖东西买家退款不退货怎么办 在闲鱼网上买东西被骗了怎么办 开通花呗的手机号不用了怎么办 饿了么开业第一天没单量怎么办 淘宝新开店铺没有人来呀怎么办 刚开的淘宝店铺没有人买东西怎么办 开了一家龙虾店生意很淡怎么办? 新买的皮质小白鞋有点板脚怎么办 手机无效安装包与系统不兼容怎么办 发好的海参放进速冻后变小了怎么办 厨房地砖下面的下水管漏水怎么办? 埋在地下的暖气管漏水怎么办 安装个视频播放器视频全没了怎么办 奇迹mu圣导转职任务打不过怎么办 丈夫死后房产证过给妻子怎么办 学业与志愿活动冲突时你会怎么办 往宅正门前面有半园幕墙玻璃怎么办 模拟城市5石油抽干了怎么办 一户一宅我父亲没有宅基怎么办? 在日本坐新干线期间车票丢了怎么办 街电共享充电宝丢了怎么办