如何自定义FragmentTabHost中某一个Tab的点击效果
1个回答
展开全部
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 );
3 加入自定义的indicator
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 );
return v;
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 );
3 加入自定义的indicator
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 );
return v;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询