首页 > 解决方案 > AndroidX recyclerview 1.0.0 vs 1.1.0 问题

问题描述

我最近将 recyclerview 1.0.0 更新为 1.1.0

一切似乎都运行良好,但现在我收到了一些罕见的崩溃报告,即视图为空

现在我设法在底部的表格中复制它,里面有一个 recyclerview

 @BindView(R.id.earningTitleTextView)
    TextView earningTitleTextView;

    @BindView(R.id.earningAmountTextView)
    TextView earningAmountTextView;


public KeEarningItemViewHolder(View itemView) {
        super(itemView);
        this.context = itemView.getContext();
        ButterKnife.bind(this, itemView);
    }

    public void setContent(KeEarnings.KeEarningItem earningItem){
        if(earningTitleTextView != null){
            earningTitleTextView.setText(earningItem.getTitle());
        }
        if(earningAmountTextView != null){
            earningAmountTextView.setText(earningItem.getValue());
        }
    }

setContent 在 onBindViewholder 方法中被调用,但似乎绑定发生在 viewHolder 完全创建之前?!EarningTitleTextView 和 EarningAmountTextView 都是空的

是否有什么完全改变了如何处理我错过的 Viewholder 或者只是新的 Recyclerview 1.1.0 中的一个错误?

标签: androidandroid-recyclerview

解决方案


推荐阅读