1.RecyclerView中,onCreateViewHolder中,如果为attachToRoot为true,会出现以下错误:
recyclerView中,已经把adapter中创建的holder中的view,addView进去,所以不可以addView两次,attachToRoot不能传入true;
具体原因:
https://blog.csdn.net/LAMP_zy/article/details/48706269
为false时,会item布局中的参数会生效,recyclerview会自动addview
@Override
protected RecyclerView.ViewHolder onCreateViewHolder(LayoutInflater inflater, ViewGroup parent, int viewType) {
return new GroupTagViewholder(inflater.inflate(R.layout.item_group_tag, parent, false));
}
2.inflater源码解析: