youth5201314 / banner

🔥🔥🔥Banner 2.0 来了!Android广告图片轮播控件,内部基于ViewPager2实现,Indicator和UI都可以自定义。
Apache License 2.0
12.9k stars 2.51k forks source link

偷懒不想自己新建适配器 #892

Closed gkj17 closed 4 years ago

gkj17 commented 4 years ago

文档说使用BannerImageAdapter<。。> 可是没有提供这个类 是忘记了吗。。。

gzl003 commented 4 years ago

/**

public abstract class BaseBannerItem extends RelativeLayout {

public BaseBannerItem(Context context) {
    this(context, null);
}

public BaseBannerItem(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
}

public BaseBannerItem(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    init(context);
}

private void init(Context context) {
    addView(createView(context));
}

/**
 * 创建布局
 *
 * @param context
 * @return
 */
protected abstract View createView(Context context);

}

gzl003 commented 4 years ago

image

gzl003 commented 4 years ago

`activeBanner.setImageLoader(new BaseBannerLoader() { private SimpleDraweeView imageView;

                    @Override
                    public View createBanner(Context context) {
                        View view = View.inflate(context, R.layout.vip_banner_layout, null);
                        imageView = view.findViewById(R.id.banner_img);
                        return view;
                    }

                    @Override
                    public void displayBanner(Object path, BaseBannerItem item) {
                        AccountActive.ActiveItem data = (AccountActive.ActiveItem) path;
                        ImageLoadHelper.displayImage(imageView, data.pic);
                    }
                }).setDelayTime(5000)`
gkj17 commented 4 years ago

不是 是这个意思,就是想图片这样 但是找不到BannerImageAdapter这个类 image

gkj17 commented 4 years ago

//—————————————————————————如果你想偷懒,而又只是图片轮播———————————————————————— banner.setAdapter(new BannerImageAdapter(DataBean.getTestData3()) { @Override public void onBindView(BannerImageHolder holder, DataBean data, int position, int size) { //图片加载自己实现 Glide.with(holder.itemView) .load(data.imageUrl) .apply(RequestOptions.bitmapTransform(new RoundedCorners(30))) .into(holder.imageView); } }) .addBannerLifecycleObserver(this)//添加生命周期观察者 .setIndicator(new CircleIndicator(this));

youth5201314 commented 4 years ago

@gkj17 你确定是用的最新版本吗?