相关疑难解决方法(0)

RecyclerView适配器getItemViewType方法有时返回2,8等等而不是0或1

以下是我使用的代码:

public class PaymentAndReceiptAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private static final int TYPE_HEADER = 0;
    private static final int TYPE_ITEM = 1;

    public Context context;
    private List<CustomerAndAmount> customerAndAmountList = new ArrayList<>();
    private PaymentAndReceiptItemClickListener paymentAndReceiptItemClickListener;
    private Map<Long, Double> chartMap;

    public PaymentAndReceiptAdapter(final Context context, final List<CustomerAndAmount> customerAndAmountList, final Map<Long, Double> chartMap, final PaymentAndReceiptItemClickListener paymentAndReceiptItemClickListener) {
        this.context = context;
        setResult(customerAndAmountList, chartMap);
        this.paymentAndReceiptItemClickListener = paymentAndReceiptItemClickListener;
    }

    public void setResult(final List<CustomerAndAmount> customerAndAmountList, final Map<Long, Double> chartMap) {
        this.customerAndAmountList.clear();
        if (null != customerAndAmountList) {
            this.customerAndAmountList.addAll(customerAndAmountList);
        }
        this.chartMap …
Run Code Online (Sandbox Code Playgroud)

android recycler-adapter android-recyclerview recyclerview-layout

5
推荐指数
0
解决办法
367
查看次数