The specified child already has a parent. You must call removeView() on the child's parent first问题
来源:互联网 发布:淘宝购物车降价提醒 编辑:程序博客网 时间:2024/06/05 03:20
今天遇到了一个问题使用frangment出现了The specified child already has a parent. You must call removeView() on the child’s parent first的错误,在stackoverflow找到了解决的方法:
…
private LayoutInflater mInflater;
private WeakReference mRootView = null;
…
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState)
{
if (inflater != null)
mInflater = inflater;
else
mInflater = LayoutInflater.from(getActivity());
View rootView = mRootView == null ? null : mRootView.get();
if (rootView != null)
{
final ViewParent parent = rootView.getParent();
if (parent != null && parent instanceof ViewGroup)
((ViewGroup) parent).removeView(rootView);
}
else
{
rootView = mInflater.inflate(R.layout.fragment_test, null, false);
mRootView = new WeakReference(rootView);
}
return rootView;
}
- 问题:The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent.You must call removeView() on the child's parent first问题
- The specified child already has a parent. You must call removeView() on the child's parent first问题
- 解决The specified child already has a parent. You must call removeView() on the child's parent first问题
- The specified child already has a parent. You must call removeView() on the child's parent first.
- 二、The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- The specified child already has a parent. You must call removeView() on the child's parent first.
- 总是报The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.解决办
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first.
- The specified child already has a parent. You must call removeView() on the child's parent first
- PAT甲级1056. Mice and Rice (25)
- HTML5多线程JavaScript解决方案Web Worker——专用Worker和共享Worker
- MFC中UpdateData函数的使用
- canvas转base64/jpeg时,透明区域变成黑色背景的解决方案
- 00、node介绍
- The specified child already has a parent. You must call removeView() on the child's parent first问题
- ifstream读取文件和stringstream读取内容
- 树的存储结构
- hdu1242 Rescue BFS+优先队列
- 选票统计
- Java的安全初始化
- python 调用 有道api接口
- leecode 解题总结:342. Power of Four
- 为什么(i++)不能做左值,而(++i)可以