本文实例为大家分享了android FragmentTabhost导航分页展示的具体代码,供大家参考,具体内容如下
基本模板
public class MainActivity extends FragmentActivity { private FragmentTabHost mTabHost; private LayoutInflater mLayoutInflater; private Class mFragmentArray[] = { Fragment1.class, Fragment2.class, Fragment3.class, Fragment4.class, Fragment5.class }; private int mImageArray[] = { R.drawable.tab_home_btn, R.drawable.tab_message_btn, R.drawable.tab_selfinfo_btn, R.drawable.tab_square_btn, R.drawable.tab_more_btn }; private String mTextArray[] = { "首页", "消息", "好友", "搜索", "更多" }; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); } private void initView() { mLayoutInflater = LayoutInflater.from(this); // 找到TabHost mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent); mTabHost.getTabWidget().setDividerDrawable(null);//去除分割线 // 得到fragment的个数 for (int i = 0; i
acitivity_main.xml
<&#63;xml version="1.0" encoding="utf-8"&#63;>
tab_item_view.xml
main_bottom_image_selector图片选择器
<&#63;xml version="1.0" encoding="utf-8"&#63;>
注:模板有5个tab,需要5个图片选择器,还需要5个文本选择器,还需要创建5个fragment。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。