youth5201314 / banner

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

setOnBannerListener点击无效,没有回调 #1184

Closed YizeLin closed 10 months ago

YizeLin commented 1 year ago

轮播图有数据正常滚动,但是setOnBannerListener点击没有回调相应 binding.homeBanner.setAdapter(new HomeBannerAdapter(homeBannerEntities)); binding.homeBanner.setOnBannerListener(new OnBannerListener() { @Override public void OnBannerClick(Object data, int position) { if(null!= data){ HomeBannerEntity entity = (HomeBannerEntity) data; if(entity.getIsNeedToken()==1){ String token = UserCenter.getInstance().getToken(); if (StringUtils.isEmpty(token)) { //未登录 startActivity(LoginActivity.class); return; } } Bundle bundle = new Bundle(); Intent intent = new Intent(); if(entity.getContentType()==1){ //跳转到帖子 // bundle.putInt("topicId", Integer.valueOf(entity.get().getTopicId())); // intent.putExtras(bundle); }else{ //跳转到H5页面 if (entity.getH5Title() != null && entity.getH5Url() != null) { bundle.putString("title", entity.getH5Title()); bundle.putString("url", entity.getH5Url()); startActivity(InternalTokenWebActivity.class, bundle); } }

                    }
                }
            });
YizeLin commented 1 year ago
implementation 'io.github.youth5201314:banner:2.2.2' 引用的事该版本
liugt34 commented 1 year ago

我也碰到这个问题了,兄弟解决了么?

liugt34 commented 1 year ago

用这个解决了 #698