总是报The specified child already has a parent. You must call removeView() on the child's parent first.
来源:互联网 发布:次世代模型师月薪知乎 编辑:程序博客网 时间:2024/04/29 13:57
// 加载控件自己的布局文件
LayoutInflater inflater = (LayoutInflater) mcontext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.home_week_calendar_layout, this);
//mLayout = (LinearLayout)this.findViewById(R.id.layout_horizontal);
LinearLayout mLayouts[] = new LinearLayout[6];
TextView mTextViews[] = new TextView[3];
params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
mLayouts[0] = (LinearLayout) this.findViewById(R.id.linearlayout);// 获取LinearLayout布局容器
mLayouts[1] = (LinearLayout) view.findViewById(R.id.linearlayout2);// 获取LinearLayout布局容器
mLayouts[2] = (LinearLayout) view.findViewById(R.id.linearlayout3);// 获取LinearLayout布局容器
mLayouts[3] = (LinearLayout) view.findViewById(R.id.linearlayout4);// 获取LinearLayout布局容器
mLayouts[4] = (LinearLayout) view.findViewById(R.id.linearlayout5);// 获取LinearLayout布局容器
mLayouts[5] = (LinearLayout) view.findViewById(R.id.linearlayout6);// 获取LinearLayout布局容器
// mLayout = (LinearLayout)this.findViewById(R.id.linearlayout);//
// 获取LinearLayout布局容器
// for (int k = 0; k > mLayouts.length; k++) {
for (int i = 0; i < mTextViews.length; i++) {
mTextViews[i] = new TextView(mcontext);
mTextViews[i].setId(i);
}
//第一个LinearLayout
mTextViews[0].setText("2/17");
mTextViews[0].setGravity(Gravity.CENTER);
mTextViews[0].setTextSize(12);
mLayouts[0].addView(mTextViews[0], params);
mTextViews[1].setText("日");
mTextViews[1].setGravity(Gravity.CENTER);
mTextViews[1].setTextSize(12);
mLayouts[0].addView(mTextViews[1], params);
for (int i = (images.length + 1); i > 0; i--) {
ImageView image = new ImageView(mcontext);// 程序创建ImageView组件
mLayouts[0].addView(image);// 将ImageView组件添加到LinearLayout布局容器中
image.setImageResource(images[0]);// 初始化时显示第一张图片
}
mTextViews[2].setText("16/7");
mTextViews[2].setGravity(Gravity.CENTER);
mTextViews[2].setTextSize(12);
mLayouts[0].addView(mTextViews[2], params);
//第二个LinearLayout
//mTextViews[0].setText("2/17");
//mTextViews[0].setTextSize(12);
mLayouts[1].addView(mTextViews[0], params);//这儿出错了
//mTextViews[1].setText("日");
//mTextViews[1].setTextSize(12);
mLayouts[1].addView(mTextViews[1], params);
//for (int i = (images.length + 1); i > 0; i--) {
// ImageView image = new ImageView(mcontext);// 程序创建ImageView组件
// mLayouts[1].addView(image);// 将ImageView组件添加到LinearLayout布局容器中
// image.setImageResource(images[0]);// 初始化时显示第一张图片
//}
//mTextViews[2].setText("16/7");
//mTextViews[2].setTextSize(12);
mLayouts[1].addView(mTextViews[2], params);
LayoutInflater inflater = (LayoutInflater) mcontext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.home_week_calendar_layout, this);
//mLayout = (LinearLayout)this.findViewById(R.id.layout_horizontal);
LinearLayout mLayouts[] = new LinearLayout[6];
TextView mTextViews[] = new TextView[3];
params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
mLayouts[0] = (LinearLayout) this.findViewById(R.id.linearlayout);// 获取LinearLayout布局容器
mLayouts[1] = (LinearLayout) view.findViewById(R.id.linearlayout2);// 获取LinearLayout布局容器
mLayouts[2] = (LinearLayout) view.findViewById(R.id.linearlayout3);// 获取LinearLayout布局容器
mLayouts[3] = (LinearLayout) view.findViewById(R.id.linearlayout4);// 获取LinearLayout布局容器
mLayouts[4] = (LinearLayout) view.findViewById(R.id.linearlayout5);// 获取LinearLayout布局容器
mLayouts[5] = (LinearLayout) view.findViewById(R.id.linearlayout6);// 获取LinearLayout布局容器
// mLayout = (LinearLayout)this.findViewById(R.id.linearlayout);//
// 获取LinearLayout布局容器
// for (int k = 0; k > mLayouts.length; k++) {
for (int i = 0; i < mTextViews.length; i++) {
mTextViews[i] = new TextView(mcontext);
mTextViews[i].setId(i);
}
//第一个LinearLayout
mTextViews[0].setText("2/17");
mTextViews[0].setGravity(Gravity.CENTER);
mTextViews[0].setTextSize(12);
mLayouts[0].addView(mTextViews[0], params);
mTextViews[1].setText("日");
mTextViews[1].setGravity(Gravity.CENTER);
mTextViews[1].setTextSize(12);
mLayouts[0].addView(mTextViews[1], params);
for (int i = (images.length + 1); i > 0; i--) {
ImageView image = new ImageView(mcontext);// 程序创建ImageView组件
mLayouts[0].addView(image);// 将ImageView组件添加到LinearLayout布局容器中
image.setImageResource(images[0]);// 初始化时显示第一张图片
}
mTextViews[2].setText("16/7");
mTextViews[2].setGravity(Gravity.CENTER);
mTextViews[2].setTextSize(12);
mLayouts[0].addView(mTextViews[2], params);
//第二个LinearLayout
//mTextViews[0].setText("2/17");
//mTextViews[0].setTextSize(12);
mLayouts[1].addView(mTextViews[0], params);//这儿出错了
//mTextViews[1].setText("日");
//mTextViews[1].setTextSize(12);
mLayouts[1].addView(mTextViews[1], params);
//for (int i = (images.length + 1); i > 0; i--) {
// ImageView image = new ImageView(mcontext);// 程序创建ImageView组件
// mLayouts[1].addView(image);// 将ImageView组件添加到LinearLayout布局容器中
// image.setImageResource(images[0]);// 初始化时显示第一张图片
//}
//mTextViews[2].setText("16/7");
//mTextViews[2].setTextSize(12);
mLayouts[1].addView(mTextViews[2], params);
0 0
- 总是报The specified child already has a parent. You must call removeView() on the child's parent first.
- . 报错 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.
- ubuntu 64位中安装安卓应用包解析工具apktool
- linux source命令
- PJNATH介绍 -- 用于NAT穿透的ICE, STUN和TURN的开源库
- DAG单源最短路径
- android:layout_weight的巧妙应用
- 总是报The specified child already has a parent. You must call removeView() on the child's parent first.
- 严重: Skipped installing application listeners due to previous error(s)
- 输出所有排列组合
- git am时出现Dirty index: cannot apply patches (dirty: hello.c)的解决方法
- A Letter of Application
- 【script】一个打渠道号的脚本
- 陈庆华:大数据让BI更精彩
- 使用 udev 高效、动态地管理 Linux 设备文件
- 如何使tableLayoutPanel 不闪烁