私はImageViewをRelativeLayoutに挿入しました。このImageViewの上に、プログレスバーを挿入しようとしています。プログレスバーは、画像がダウンロードされた後は見えなくなります。しかし、ImageViewを追加した後にプログレスバーを追加すると、エラーが表示される -RelativeLayoutのビューを動的に重ねる方法は?
java.lang.IllegalStateException:指定された子にはすでに親があります。子の親で最初にremoveView()を呼び出す必要があります。ここで
コードは次のとおりです。
mRelativeLayout = (RelativeLayout) mGallery.findViewById(R.id.relative_progress_spin_layout);
RelativeLayout.LayoutParams relativeLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
relativeLayoutParams.addRule(RelativeLayout.ALIGN_TOP, R.id.progress_spin);
progressBar = (ProgressBar) mGallery.findViewById(R.id.progress_spin);
image = new ImageView(GalleryModuleActivity.this);
image.setPadding(4, 4, 4, 4);
image.setScaleType(ImageView.ScaleType.FIT_XY);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(200, LinearLayout.LayoutParams.MATCH_PARENT);
image.setLayoutParams(layoutParams);
mRelativeLayout.addView(image);
mRelativeLayout.addView(progressBar);
mHorizontalLayout.addView(mRelativeLayout);
おかげ..
ありがとうslukian !!出来た。 – FireAndIce