public void vpSet() { viewPager = (ViewPager)findViewById(R.id.vpWelcome); pagerTitle = (PagerTitleStrip)findViewById(R.id.ptWelcome); //添加页面 inflater = LayoutInflater.from(this); view1 = inflater.inflate(R.layout.welcome_vp_1, null); view2 = inflater.inflate(R.layout.welcome_vp_2, null); view3 = inflater.inflate(R.layout.welcome_vp_3, null); views = new ArrayList<View>(); views.add(view1); views.add(view2); views.add(view3); //添加页面标题 titles = new ArrayList<String>(); titles.add(getString(R.string.welcome)); titles.add(getString(R.string.help)); titles.add(getString(R.string.start)); //添加数据适配器 PagerAdapter pagerAdapter = new PagerAdapter() { @Override public int getCount() { return views.size(); } @Override public CharSequence getPageTitle(int position) { return titles.get(position); } @Override public Object instantiateItem(View view, int position) { ((ViewPager)view).addView(views.get(position)); return views.get(position); } @Override public void destroyItem(View view, int position, Object object) { ((ViewPager)view).removeView(views.get(position)); } @Override public boolean isViewFromObject(View view, Object object) { return view == object; } }; viewPager.setAdapter(pagerAdapter); }
部分代码如上
我不想用几个testview做viewPager的标题,但是又想达到点击某个标题就能跳转到那个界面的效果
用PagerTitleStrip怎么实现这个效果啊?
还是小白一只,麻烦说详细一点,谢谢啦~
PaperTitleStrip是什么东西?
viewPager又是什么东西?