标签:tabhostfragment android indicator 标题
1 获得 tabHostFragment:
ActionBarActivity activity2 = (ActionBarActivity) activity;
mTabHost = new FragmentTabHost(activity2);
mTabHost.setup(getActivity(),getChildFragmentManager(),R.id.content_frame);
2 加入系统默认的indicator
mTabHost.addTab(mTabHost.newTabSpec("tour").setIndicator("巡视"),TourFragmentTab.class,null);
indicator = getIndicatorView("任务", R.layout.tab_custom);
mTabHost.addTab(mTabHost.newTabSpec("task").setIndicator(indicator),TaskFragment.class,null);
4 上面用到的getIndicatorView方法如下:private View indicator = null;
public View getIndicatorView(String name, int layoutId) {
View v = getActivity().getLayoutInflater().inflate(layoutId, null);
TextView tv = (TextView) v.findViewById(R.id.tabText);
tv.setText(name);
return v;
}
如何 TabHostFragment自定义 tab键(indicator),布布扣,bubuko.com
如何 TabHostFragment自定义 tab键(indicator)
标签:tabhostfragment android indicator 标题
原文地址:http://blog.csdn.net/zqx198810/article/details/25329513