Android选项卡,一直报“TabWidget with id "android:id/tabs".”这个错,试了好几个API都不行
答案:1 悬赏:10
解决时间 2021-01-15 12:45
- 提问者网友:蓝莓格格巫
- 2021-01-14 23:01
Android选项卡,一直报“TabWidget with id "android:id/tabs".”这个错,试了好几个API都不行
最佳答案
- 二级知识专家网友:山河有幸埋战骨
- 2021-01-15 00:35
在布局中用TabHost,必须有一个TabWidget的子控件,并且控件id一定要是android预先定义的“android:id/tabs”,你只写一个TabHost当然会报这个错追问TabHost和TabWidget是什么关系有什么区别?是父子关系还是同一级的关系?那第一步是先拖哪个控件?求教了追答父子关系
TabHost内部有两个子控件,TabWidget和TabContent,就是选项卡切换按钮和选项卡容器,类型分别是TabWidget和FrameLayout
下面是布局例子,注意TabWidget和FrameLayout的id
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
android:id="@+id/linearLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill" >
TabHost内部有两个子控件,TabWidget和TabContent,就是选项卡切换按钮和选项卡容器,类型分别是TabWidget和FrameLayout
下面是布局例子,注意TabWidget和FrameLayout的id
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="fill" >
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息