All Products
Search
Document Center

Carousel component

Last Updated: May 25, 2021

AUBannerView is used for achieving image carousel.

Sample image

The AUTitleBar control in white is provided by default.

Dependency

See Quick start.

Sample code

 
  1. BannerView bannerView = new BannerView(this, 1000);
  2. layout.addView(bannerView);
  3. List<BannerView.BannerItem> items = new ArrayList<BannerView.BannerItem>();
  4. items.add(new BannerView.BannerItem());
  5. items.add(new BannerView.BannerItem());
  6. items.add(new BannerView.BannerItem());
  7. final List<String> list = new ArrayList<String>();
  8. String color1 = "#111111";
  9. String color2 = "#666666";
  10. String color3 = "#eeeeee";
  11. list.add(color1);
  12. list.add(color2);
  13. list.add(color3);
  14. BannerView.BaseBannerPagerAdapter adapter = new BannerView.BaseBannerPagerAdapter(bannerView,items) {
  15. @Override
  16. public View getView(ViewGroup container, int position) {
  17. TextView tv = new TextView(CarouselActivity.this);
  18. tv.setBackgroundColor(Color.parseColor(list.get(position)));
  19. container.addView(tv);
  20. return tv;
  21. }
  22. };
  23. bannerView.setAdapter(adapter);