Giter Site home page Giter Site logo

Comments (4)

CymChad avatar CymChad commented on May 1, 2024

请贴具体代码

from baserecyclerviewadapterhelper.

Jensen0618 avatar Jensen0618 commented on May 1, 2024

代码在这里,麻烦帮我看看

......
quickAdapter = new QuickAdapter(CoinActivity.this, R.layout.item_rv_mall_coin_product, listProduct);
rvMallCoinList.setLayoutManager(new LinearLayoutManager(CoinActivity.this));
rvMallCoinList.setAdapter(quickAdapter);

public class QuickAdapter extends BaseQuickAdapter<CoinListEntity.DataBean.ListBean> {

        public QuickAdapter(Context context, int layoutResId, List data) {
            super(context, layoutResId, data);
        }


        @Override
        protected void convert(BaseViewHolder baseViewHolder, CoinListEntity.DataBean.ListBean listBean) {
            baseViewHolder.setImageUrl(R.id.iv_coin_bg, listBean.getMainPic()).
                    setText(R.id.tv_coin_title, listBean.getTitle()).
                    setText(R.id.tv_coin_price, getString(R.string.money) + " " + listBean.getPrice()).
                    setText(R.id.tv_coin_coin, listBean.getJifen());
        }

    }

......
 app.volleyPostRequest(Constans.TAG_PRODUCT_LIST, Constans.PRODUCT_LIST, new Response.Listener<String>() {
            @Override
            public void onResponse(String response) {
                CoinListEntity result = GsonTool.getGsonData(response, CoinListEntity.class);
                if (result.getErrorno() == Constans.NORMAL) {
                    if (!"0".equals(result.getData().getTotal())) {
                        if (listProduct == null) {
                            listProduct = result.getData().getList();
                        } else {
                            listProduct.clear();
                            listProduct.addAll(result.getData().getList());

                        }
//如果直接在数据下载完成后使用setAdapter()方法数据就显示正常
//                        rvMallCoinList.setAdapter(quickAdapter);
                        quickAdapter.notifyDataSetChanged();
                    }
                } else {
                    app.showToast("没有数据");
                }


            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {

            }
        }, params);

from baserecyclerviewadapterhelper.

CymChad avatar CymChad commented on May 1, 2024

你可以使用setNewData这个函数

from baserecyclerviewadapterhelper.

CymChad avatar CymChad commented on May 1, 2024

为什么notifyDataSetChanged()方法不起作用,是因为你在初始化adapter的时候list为null,所以我会给你new一个list,你后续再添加值在notifyDataSetChanged()那不是同一list的了肯定不会有效果,除非你在初始化的时候就把list new出来,或者你就用setNewData方法,也可以用getData拿到里面的集合,再来设置值,这样就有效果了

from baserecyclerviewadapterhelper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.