All Products
Search
Document Center

Mobile Platform as a Service:Carousel component

Last Updated:Jul 21, 2023

AUBannerView is used for achieving image carousel.

Sample image

The AUTitleBar control in white is provided by default.

image.png

Dependency

See Quick start.

Sample code

        BannerView bannerView = new BannerView(this, 1000);
        layout.addView(bannerView);

        List<BannerView.BannerItem> items = new ArrayList<BannerView.BannerItem>();
        items.add(new BannerView.BannerItem());
        items.add(new BannerView.BannerItem());
        items.add(new BannerView.BannerItem());
        final List<String> list = new ArrayList<String>();
        String color1 = "#111111";
        String color2 = "#666666";
        String color3 = "#eeeeee";
        list.add(color1);
        list.add(color2);
        list.add(color3);

        BannerView.BaseBannerPagerAdapter  adapter = new BannerView.BaseBannerPagerAdapter(bannerView,items) {
            @Override
            public View getView(ViewGroup container, int position) {
                TextView tv = new TextView(CarouselActivity.this);
                tv.setBackgroundColor(Color.parseColor(list.get(position)));
                container.addView(tv);
                return tv;
            }
        };

        bannerView.setAdapter(adapter);