2013년 3월 26일 화요일

specified child already has parent

this is incorrect:

ImageView imageView = new ImageView(this);

for(int i=0; i<5; i++) {
imageView.setPadding(10, 10, 10, 10);
layoutParams.setMargins(10, 10, 10, 10);
layoutParams.gravity = Gravity.TOP;
   imageView.setBackgroundColor(Color.BLUE);
container.addView(imageView, layoutParams);
}






this is correct:


for(int i=0; i<5; i++) {
ImageView imageView = new ImageView(this);
imageView.setPadding(10, 10, 10, 10);
layoutParams.setMargins(10, 10, 10, 10);
layoutParams.gravity = Gravity.TOP;
    imageView.setBackgroundColor(Color.BLUE);
container.addView(imageView, layoutParams);
}

댓글 없음:

댓글 쓰기