是否可以仅在布局xml文件中定义选项卡布局?每次我找到tabhost教程时,它只适用于一些额外的java代码.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/linearLayout">
<TextView android:text="@string/app_name" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/textView1" android:textAppearance="?android:attr/textAppearanceLarge"></TextView>
<TabHost android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent">
<TabWidget android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@android:id/tabs">
</TabWidget>
<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@android:id/tabcontent">
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab1">
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="TAB 1"/>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tab2">
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="TAB 2"/>
</LinearLayout>
</FrameLayout>
</TabHost>
</LinearLayout>
解决方法:
它是不可能的,因为TabSpec是持有者类,代表TabHost中的每个选项卡.
并且没有指定要在xml布局中放置的TabSpec xml等效标记.
即使通过代码,对于TabSpec,也必须指定指标和内容.否则它会抛出
IllegalArgumentException: you must specify a way to create the tab content
要么
IllegalArgumentException: you must specify a way to create the tab indicator.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。