以下是我使用的代码:
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