In my android project, I created Generic RecyclerView's Adapter class & Viewholder class like below,

Adapter class, 

```
public class BaseRecyclerViewAdapter extends RecyclerView.Adapter<BaseViewHolder> {

    private ItemClickListener itemClickListener;
    private List<? extends Object> objectArrayList;
    private int layout;
    private BaseViewHolder baseViewHolder;

    public BaseRecyclerViewAdapter(int layout, ItemClickListener itemClickListener, List<? extends Object> objectArrayList) {
        this.layout = layout;
        this.itemClickListener = itemClickListener;
        this.objectArrayList = objectArrayList;
    }

    public BaseRecyclerViewAdapter(BaseViewHolder baseViewHolder, int layout,
                                   ItemClickListener itemClickListener, List<? extends Object> objectArrayList) {
        this.baseViewHolder = baseViewHolder;
        this.layout = layout;
        this.itemClickListener = itemClickListener;
        this.objectArrayList = objectArrayList;
    }

    @NonNull
    @Override
    public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(layout, parent, false);
        return new BaseViewHolder(itemView, itemClickListener);
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {

    }

    @Override
    public int getItemCount() {
        return objectArrayList.size();
    }
}

```

ViewHolder class

```
public class BaseViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {

    private CardView cardView;
    private AppCompatImageView imgEdit;
    private AppCompatImageView imgDelete;
    private ItemClickListener itemClickListener;

    public BaseViewHolder(View itemView, ItemClickListener itemClickListener) {
        super(itemView);
        cardView = itemView.findViewById(R.id.cardView);
        imgEdit = itemView.findViewById(R.id.imgEdit);
        imgDelete = itemView.findViewById(R.id.imgDelete);
        imgDelete.setOnClickListener(this);
        cardView.setOnClickListener(this);
        cardView.setOnLongClickListener(this);
        this.itemClickListener = itemClickListener;
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == cardView.getId()) {
            itemClickListener.onClick(view, getLayoutPosition(), ConstantCodes.ACTION_CLICK);
        } else if (view.getId() == imgDelete.getId()) {
            itemClickListener.onClick(view, getLayoutPosition(), ConstantCodes.ACTION_DELETE);
        } else if (view.getId() == imgEdit.getId()) {
            itemClickListener.onClick(view, getLayoutPosition(), ConstantCodes.ACTION_EDIT);
        }
    }

    @Override
    public boolean onLongClick(View view) {
        itemClickListener.onLongClick(view, getLayoutPosition());
        return false;
    }
}

```

Here is the way I implement the above adapter & viewholder in my activity class 

```
private class DispatchViewHolder extends BaseViewHolder {
    AppCompatTextView txtInvoiceNo;
    AppCompatTextView txtVehicleNo;
    AppCompatTextView txtPartyName;
    AppCompatTextView txtNoOfBags;
    AppCompatTextView txtMaterialType;
    AppCompatTextView txtWeight;

    DispatchViewHolder(View itemView, ItemClickListener itemClickListener) {
        super(itemView, itemClickListener);
    }
}

private class DispatchMaterialAdapter extends BaseRecyclerViewAdapter {

    ItemClickListener itemClickListener;
    List<? extends Object> objectArrayList;

    DispatchMaterialAdapter(ItemClickListener itemClickListener, List<? extends Object> objectArrayList) {
        super(R.layout.dispatch_material_row, itemClickListener, objectArrayList);
        this.itemClickListener = itemClickListener;
        this.objectArrayList = objectArrayList;
    }

    @NonNull
    @Override
    public DispatchViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.dispatch_material_row, parent, false);
        return new DispatchViewHolder(itemView, itemClickListener);
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
        try {
            DispatchViewHolder dispatchViewHolder = (DispatchViewHolder) holder;
            DispatchMaterialMd dispatchMaterialMd = (DispatchMaterialMd) objectArrayList.get(position);
            dispatchViewHolder.txtInvoiceNo.setText(dispatchMaterialMd.getInvoiceNo());
            dispatchViewHolder.txtVehicleNo.setText(dispatchMaterialMd.getVehicleNo());
            dispatchViewHolder.txtPartyName.setText(dispatchMaterialMd.getPartyName());
            dispatchViewHolder.txtNoOfBags.setText(dispatchMaterialMd.getNoOfBags());
            dispatchViewHolder.txtMaterialType.setText(dispatchMaterialMd.getMaterialType());
            dispatchViewHolder.txtWeight.setText(dispatchMaterialMd.getWeight());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public int getItemCount() {
        return dispatchMaterialMds.size();
    }
}

```

I have data in my objectArrayList list. I can print it in console, but nothing is coming in recyclerview. In recyclerview, it is only displaying empty Textview. 

Following way, implement recyclerview, 

```
layoutManager = new LinearLayoutManager(this);
dispatchMaterialAdapter =
                new DispatchMaterialAdapter(itemClickListener, dispatchMaterialMds);
            recycleListDetail.setLayoutManager(layoutManager);
            recycleListDetail.setAdapter(dispatchMaterialAdapter);

```

dispatchMaterialMds is an arraylist of model class which is filled from the database's data.

Can you please help me, why my data is not getting displayed ?