【发布时间】:2013-12-24 05:29:22
【问题描述】:
我这样做是动态地向自定义视图 (FrameLayout) 添加和删除视图:
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mMyView = inflater.inflate(resId, this, true);
稍后我尝试删除视图,但视图不会删除:
removeView(mMyView);
如果我这样做,一切都会按预期工作:
mMyView = inflater.inflate(resId, this, **false**);
addView(mMyView);
唯一的区别是我手动添加视图,而不是让 inflate 调用来完成。 有谁知道为什么这会有所作为?
【问题讨论】: