超简单Xbanner轮播

依赖

项目的gradle
maven { url 'https://jitpack.io' }
model的gradle
implementation 'com.github.xiaohaibin:XBanner:1.6.1'

布局


网络请求完数据后成功的方法

	@Override
    public void success(BannerBean data) {
        final BannerBean myBanner = (BannerBean) data;
        result = myBanner.getResult();
        for (int i = 0; i < result.size(); i++) {
            datas.add(result.get(i).getImageUrl());
        }
        if (!datas.isEmpty()) {
            xbanner.setData(result, null);
            xbanner.loadImage(new XBanner.XBannerAdapter() {
                @Override
                public void loadBanner(XBanner banner, Object model, View view, int position) {
                    Glide.with(getActivity()).load(result.get(position).getImageUrl()).into((ImageView) view);
                }
            });
            //横向移动
            xbanner.setPageTransformer(Transformer.Default);
        }
    }

你可能感兴趣的:(超简单Xbanner轮播)