我正在尝试在 Fragment 中添加 TabHost 布局:
public class FriendsTabFregment extends Fragment {
private TabHost tab;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_friends, container, false);
tab = (TabHost) view.findViewById(R.activity_friends.tab);
return view;
}
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addNewTab("Friends", BasicFragment.class, savedInstanceState); //Chat Tab
setTabHeight(50);
}
出于某种原因,我将选项卡设为空。这是我的 XML:
<TabHost android:id="@+activity_friends/tab"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="4">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
</TabHost>
</LinearLayout>
知道为什么吗?