java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
来源:互联网 发布:周芷若结局 知乎 编辑:程序博客网 时间:2024/05/16 10:21
使用viewpager时遇到的一个问题:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child’s parent first.
错误的意思是孩子已经有父母 需要使用removeView() 方法先从父母上移除才能使用add()方法。
那么怎么解决呢?
获取孩子的父母级 使用removeView
解决办法是在instantiateItem中使用如下方式:
ViewGroup parent = (ViewGroup) v.getParent();
if (parent != null) {
parent.removeAllViews();
}
container.addView(v);
阅读全文
0 0
- java.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
- java.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView(
- ava.lang.IllegalStateException: The specified child already has a parent. You must call removeView()
- ava.lang.IllegalStateException The specified child already has a parent. You must call removeView()
- Android—java.lang.IllegalStateException: The specified child already has a parent. You must call rem
- Html-2.图片和连接
- 丑数
- Unity 工作经历+近期面试经历
- Linux 设备驱动概述
- git学习笔记整理-7-打标签
- java.lang.IllegalStateException: The specified child already has a parent. You must call removeView
- 《利用Python进行数据分析》笔记---第10章时间序列
- TensorFlow官方中文文档-读书笔记
- chatterbot连接本地数据库
- 注解(笔记)
- nginx: [emerg] bind() to 0.0.0.0:9090 failed (13: Permission denied)
- 常用集合Map,List,Set
- Springmvc分页
- 【偶现】【reboot】【一】java.lang.RuntimeException