标签:
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)
标签:
原文地址:http://www.cnblogs.com/gcczhongduan/p/5141418.html