The correct way of implementing getItemId() in RecyclerView.Adapter
问题 I have generic class public abstract class BaseAdapter<T> extends RecyclerView.Adapter { private List<T> itemsList = new ArrayList<>(); //other override methods @Override public long getItemId(int position) { return position; } } What is the correct way to implementing getItemId()? I think that return position like in many example is not correct. 回答1: Create a base interface that has a method that returns a type long eg. interface BaseInterface{ long getId(); } Change abstract class