用recyclerview的时候出现了这个问题:
07-03 23:18:25.204: E/AndroidRuntime(8013): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.解决方案是在MyAdapter extends Recyclerview.Adapter里:
@Override
public Holder onCreateViewHolder(ViewGroup parent, int arg1) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View view = inflater.inflate(R.layout.activity_main1,parent,false); //或者这样参数:(xml,null)
return new Holder(view);
}
参考资料: