android编程之代码布局(常见错误)
来源:互联网 发布:java里的goto 编辑:程序博客网 时间:2024/05/21 09:25
一、Caused by:java.lang.IllegalStateException: The specified child already has a parent.
造成这个原因,是组件在父类中重复加载了相同的组件
例如:
TextView mTextView = new TextView(this); mTextView.setText("hello world"); LinearLayout.LayoutParams mLayoutParams = new LinearLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); // 第一次添加 mLinearLayout.addView(mTextView, mLayoutParams); // 第二次添加 mLinearLayout.addView(mTextView, mLayoutParams);
这样的话,我们重复添加了两次mTextView。这个是不允许的,在父类布局中,只能有唯一的对象,不能重复。
如果你想建立两个相同的组件,还是费力一下,再创建一个对象吧。o(╯□╰)o
未完,待续。。。。
- android编程之代码布局(常见错误)
- android编程之代码布局(常见错误)
- android编程之代码布局(常见错误)
- android编程之代码布局(一)
- android编程之代码布局(二)
- android编程之代码布局(三)
- android编程之代码布局(一)
- android编程之代码布局(二)
- android编程之代码布局(三)
- android编程之代码布局(一)
- android编程之代码布局(二)
- android编程之代码布局(三)
- android编程之代码布局(一)
- android编程之代码布局(一)
- android编程之代码布局(二)
- android编程之代码布局(三)
- android编程之代码布局
- android编程之代码布局
- D3D游戏编程系列(一):DXLib的介绍
- spoj lcs2 后缀自动机SAM
- (组合数学3.1.2.1)POJ 2249 Binomial Showdown(排列组合公式的实现)
- android persistent属性研究
- 台风
- android编程之代码布局(常见错误)
- 关于产品的一些思考——腾讯之微信
- Spring常用注解
- Android推送 采用XMPP协议实现
- 国际化
- 2014美团网笔试题目(总结)
- android - 自定义标题栏(在标题栏中增加按钮和文本居中)
- 蒙特卡洛法求Pi
- DevExpress GridControl使用方法总结