android fragmenttabhost怎么用

发布网友

我来回答

1个回答

热心网友

布局 中添加:

<android.support.v4.app.FragmentTabHost
android:id="@+id/prize_tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >

</android.support.v4.app.FragmentTabHost>

再在fragment中
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.frg_prize, container, false);
mTabHost = (FragmentTabHost) view.findViewById(R.id.prize_tabhost);
mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.prize_title);
mTabHost.addTab(mTabHost.newTabSpec(“tag”).setIndicator(“NAME”),
fragment, null);
mTabHost.addTab(mTabHost.newTabSpec(“tag1”).setIndicator(“NAME1”),
fragment, null);

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com