学了好久,原来是被Android的几个bug搞得分不清方向了!
android.support.v4.app.FragmentTabHost这个东西有点bug,原因是3.0留下的问题,而为了兼容性,所以3.0以后的不再(官方推荐)使用TabActivity这变态东西,推荐使用Fragment代替,因而tabcontent也随之废弃掉(不是真正的废弃)。二网上还有很多关于Tabactivity过时的例子。要想使用tabhost这个功能,并使用fragmen,因而有以下这个变态的布局:
<span style="font-family: Arial, Helvetica, sans-serif;">
</span>
<span style="font-family: Arial, Helvetica, sans-serif;"><android.support.v4.app.FragmentTabHost</span>
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<span style="color:#ff0000;"><FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/></span>
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<TabWidget
android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"/>
</LinearLayout>
</android.support.v4.app.FragmentTabHost>
(红色字段,看到没?
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0"/
只能设置为0,也就是说把这个
tabcontent过时的老家伙强制隐藏掉
)。
希望Android的下一个bug不要这么蛋疼!!!
有时候一连几天在学习那个BUG!学到你想崩溃,但有不能崩溃的境界
![](http://ctc.qzs.qq.com/qzone/em/e119.gif)
![](http://ctc.qzs.qq.com/qzone/em/e104.gif)
![](http://ctc.qzs.qq.com/qzone/em/e136.gif)
![](http://ctc.qzs.qq.com/qzone/em/e129.gif)
![](http://ctc.qzs.qq.com/qzone/em/e108.gif)
真的是要:苦其心志劳其筋骨饿其体肤、空乏其身、行拂乱其所为、所以动心忍性增益其所不能。