1 ViewPager pager = (ViewPager) findViewById(R.id.pager1); 2 pager.setAdapter(new Main2Activity.MyPagerAdapter2(getSupportFragmentManager())); 3 4 PagerSlidingTabStrip tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs1); 5 tabs.setViewPager(pager); 6 7 8 public class MyPagerAdapter2 extends FragmentPagerAdapter { 9 10 private final String[] TITLES = { 11 "招生管理", "市场管理", "学生管理", "教学管理", "教务管理", "财务管理", 12 "职工管理", "日常办公","家校联络" }; 13 14 public MyPagerAdapter2(FragmentManager fm) { 15 super(fm); 16 } 17 18 @Override 19 public CharSequence getPageTitle(int position) { 20 return TITLES[position]; 21 } 22 23 @Override 24 public int getCount() { 25 return TITLES.length; 26 } 27 28 @Override 29 public Fragment getItem(int position) { 30 return SuperAwesomeCardFragment.newInstance(position,TITLES); 31 } 32 33 }
1 <com.astuetz.PagerSlidingTabStrip 2 android:id="@+id/tabs1" 3 android:layout_width="match_parent" 4 android:layout_height="48dip" 5 app:pstsIndicatorColor="#939393" 6 app:pstsIndicatorHeight="5dp" 7 app:pstsDividerColor="#d3d3d3" 8 app:pstsUnderlineColor="#d3d3d3" 9 app:pstsTabPaddingLeftRight="10dp" /> 10 <android.support.v4.view.ViewPager 11 android:layout_width="match_parent" 12 android:layout_height="wrap_content" 13 android:id="@+id/pager1" 14 android:layout_below="@+id/tabs1"> 15 16 </android.support.v4.view.ViewPager>
时间: 2024-11-08 16:31:33