给引导页添加pageControl

导航点在Android里面其实就是一个个图片,在ios里面是PageControl;
需要在xml里面的ViewPager布局里面添加ImageView,使用的时候实现接口:
implements ViewPager.OnPageChangeListener {
在其中的onPageSelected(int position)里面实现图片内容的切换:
public class Guide extends Activity implements ViewPager.OnPageChangeListener {

private ViewPager vp;
private ViewPagerAdapter vpAdapter;
private Listviews;
private ImageView[] dots;
private int[] ids = {R.id.iv1,R.id.iv2,R.id.iv3};

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.guide);
    initViews();
    initDots();
}

private void initViews(){

    LayoutInflater inflater = LayoutInflater.from(this);

    views = new ArrayList();
    views.add(inflater.inflate(R.layout.one,null));
    views.add(inflater.inflate(R.layout.two,null));
    views.add(inflater.inflate(R.layout.three,null));

    vpAdapter = new ViewPagerAdapter(views,this);
    vp = (ViewPager)findViewById(R.id.viewPager);
    vp.setAdapter(vpAdapter);
    vp.addOnPageChangeListener(this);

}

private void initDots(){
    dots = new ImageView[views.size()];
    for (int i=0;i

}

你可能感兴趣的:(给引导页添加pageControl)