今天用Android Studio,在布局中用TabHost报错:
Exception raised during rendering: TabHost requires a FrameLayout with id "android:id/tabcontent"
这是因为TabHost内部有两个子控件,TabWidget和TabContent,就是选项卡切换按钮和选项卡容器,类型分别是TabWidget和FrameLayout,所以TabHost必须有一个TabWidget的子控件,并且控件id一定要是android预先定义的“android:id/tabs”,如果只写一个FrameLayout不加id当然会报这个错
所以,在FrameLayout中加一个id就行了
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="0.0dip"
android:layout_weight="1.0" />