1、Android studio报错:
The specified child already has a parent. You must call removeView() on the child's parent first.
此时是需要查看当前加载的布局界面,
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item_income_detail, parent);
给inflate()增添一个AttachToRoot的参数,设为false,问题解决。
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item_income_detail, parent,
false);
2、继承了RecyclerView.Adapter时,部分布局不显示出来,如图:
解决办法是:
View view = LayoutInflater.from(context).inflate(R.layout.rv_item_income_detail, parent,false);
改为
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rv_item_income_detail, parent,
false);
获取父的context。
具体原因还需进一步了解。