自动轮播

第一步添加依赖

compile 'com.jude:rollviewpager:1.4.5'

自动轮播图第二步在xml中写控件rollpageview

第三部写代码控件名字

roll_lunbo = (RollPagerView) findViewById(R.id.roll_lunbo);

//图片的集合int arr[]={R.mipmap.d,R.mipmap.e,R.mipmap.f}; final ListimageList=new ArrayList<>();

        for (int i = 0; i <3 ; i++) {

            ImageView imageView = new ImageView(this);

            imageView.setImageResource(arr[i]);

            imageList.add(imageView);

        }

//轮播的时间

        roll_lunbo.setPlayDelay(2000);

//设置轮播适配器

        roll_lunbo.setAdapter(new StaticPagerAdapter() {

            @Override

            public View getView(ViewGroup container, int position) {

                return imageList.get(position);

            }

            @Override

            public int getCount() {

                return imageList.size();

            }

        });

你可能感兴趣的:(自动轮播)