不得不说,看源码使人成长,哈哈哈哈哈。
主要是对onCreateViewHolder这个方法
public abstract VH onCreateViewHolder(ViewGroup parent, int viewType);
里面的参数parent的来源不熟悉、不知道是什么鬼。于是就去看源码。首先看这个方法的注释
/**
* Called when RecyclerView needs a new {@link ViewHolder} of the given type to represent
* an item.
* <p>
* This new ViewHolder should be constructed with a new View that can represent the items
* of the given type. You can either create a new View manually or inflate it from an XML
* layout file.
* <p>
* The new ViewHolder will be used to display items of the adapter using
* {@link #onBindViewHolder(ViewHolder, int, List)}. Since it will be re-used to display