文章目录
  1. 1.
  2. 2. 使用

使用

1
2
3
4
5
6
7
8
9
10
11
LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflator.inflate(R.layout.custom_ab,null);
tabBarView = (TabBarView) v.findViewById(R.id.tab_bar);

getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_SUSTOM);
getActionBar().setCustomView(v);

mSectionsPagerAdapter = new SectionsPagerAdapter(getFramentManager());

mViewPager = (ViewPager) findViewById(R.id.pager);
tabBarView.setViewPager(mViewPager);

实现一个adapter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class SectionsPagerAdapter extends FragmentPagerAdapter implements IconTabProvider {
private intp[] tab_icons = {R.drawable.ic_tab1,R.drawable.ic_tab2,R.drawable.ic_tab3};

public SectionsPagerAdapter(FragmentManager fm){
super(fm);
}

@Override
public Fragment getItem(int position) {
return PlaceholderFragment.newInstance(position + 1);
}

@Override
public int getCount() {
return tab_icons.length;
}

@Override
public CharSequence getPageTitle(int position) {
Locale l = Locale.getDefault();
switch (position) {
case 0:
return getString(R.string.title_section1).toUpperCase(l);
case 1:
return getString(R.string.title_section2).toUpperCase(l);
case 2:
return getString(R.string.title_section3).toUpperCase(l);
}
return null;
}
}

===
TabBarView

文章目录
  1. 1.
  2. 2. 使用