LillteZheng / ViewPagerHelper

这个一个 viewpager/viewpager2工具类,能够帮你快速实现导航栏轮播图,app引导页,viewpager/viewpager2 + fragment;内置多种tab指示器,让你告别 viewpager 的繁琐操作,专注逻辑功能
Apache License 2.0
1.17k stars 162 forks source link

下拉刷新 广告banner 下面指示器成倍增加如何破啊 #13

Closed daiwenbing closed 6 years ago

LillteZheng commented 6 years ago

你好,麻烦你把下拉之后的数据填充写上来,我看一下

daiwenbing commented 6 years ago
public void inittopPager(){
    //配置pagerbean,这里主要是为了viewpager的指示器的作用,注意记得写上泛型
    PageBean  beans = new PageBean.Builder<BannerListModel.data>()
            .setDataObjects(bannerlist)
            .setIndicator(viewHolderHead.bottomScaleLayout)
            .builder();
    // 设置viewpager的动画,这里提供了三种,分别是MzTransformer,ZoomOutPageTransformer,
    // 和DepthPageTransformer,可以体验一下

// viewHolderHead.loopViewpager.setPageTransformer(false,new MzTransformer()); // viewHolderHead.loopViewpager.setPageListener(beans, R.layout.image_layout, new PageHelperListener() { @Override public void getItemView(View view, final Object data) { ImageView imageView = (ImageView) view.findViewById(R.id.page_icon); final BannerListModel.data bean = (BannerListModel.data) data; Glide.with(getActivity()) .load(bean.getPic()) .placeholder(R.mipmap.loag_station_banner) .into(imageView); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toppager_click(bean); } }); } }); }

LillteZheng commented 6 years ago

你的beans在下拉之后,是不是没清除?

daiwenbing commented 6 years ago

beans不是没次new的吗 没次刷新调用 inittopPager() 数据长度不变 没找到哪里问题

LillteZheng commented 6 years ago

晚上下班我写个demo看一下,或者你把你的demo发一下我,845731923@qq.com

daiwenbing commented 6 years ago

好的 我在正式项目上弄 想换成你这个 之前弄的没有刷新

daiwenbing commented 6 years ago

` //轮播banner GsonRequest request_banner = new GsonRequest(Request.Method.POST, DSLConnections.GETBANNERLIST, BannerListModel.class, null, new Response.Listener() { @Override public void onResponse(BannerListModel model) { bannerListModel = model; return_banner(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError arg0) { // Toast.makeText(getActivity(), VolleyErrorHelper.getMessage(arg0,getActivity()),Toast.LENGTH_SHORT).show(); } }); request_banner.setTag("tag"); DSLApplication.getHttpQueue().add(request_banner);

/**
 * 广告 banner viewpager
 */
public void return_banner() {
    try {
        if ("0000".equals(bannerListModel.getErrorCode())) {
            bannerlist.clear();
            bannerlist.addAll(bannerListModel.getData());
            inittopPager();
        }
    } catch (NullPointerException e) {
    }
}`
daiwenbing commented 6 years ago

老哥 在PageBean之前做下判断就好了

if (viewHolderHead.bottomScaleLayout!=null){ viewHolderHead.bottomScaleLayout.removeAllViews(); } PageBean beans = new PageBean.Builder() .setDataObjects(bannerlist) .setIndicator(viewHolderHead.bottomScaleLayout) .builder();

LillteZheng commented 6 years ago

666

LillteZheng commented 6 years ago

感谢反馈