The specified child already has a parent. You must call removeView() on the child's parent first
处理方法是在adapter里面:
@Override
public Object instantiateItem(ViewGroup container, int position) {
View itemView = mViews.get(position);
/*
* 这个问题是因为一个View只能隶属于一个parent,你的代码应该是changeView函数中的第二个循环中,
* 将itemView指向的View重新添加到container中去了
* 。只要在tableRow.addView(img)之前加上:((ViewGroup
* )itemView.getParent()).removeView(itemView);应该就可以了。
*/
((ViewGroup) itemView.getParent()).removeView(itemView);
container.addView(itemView);
return itemView;
}