I have created a dialog and did setview(view) for that dialog.
very first time this view attached to that dialog and dialog is popping up without any problem.
but the second time , when you do setview(view) .. it will throw the below error.
Error :The specified child already has a parent. You must call removeView() on the child's parent first.
Solution:
Create a layout and add imageview in that xml.
inflate the xml and set that imageview in the alertdialog.
View dialoglayout = inflater.inflate(R.layout.scale_image, null);
ImageView view2 = (ImageView) dialoglayout.findViewById(R.id.enlargeImage);
view2.setImageBitmap(scaledBitmap);
alertdialog.setView(dialoglayout);
alertdialog.show();
Above piece of code solved my issue .
very first time this view attached to that dialog and dialog is popping up without any problem.
but the second time , when you do setview(view) .. it will throw the below error.
Error :The specified child already has a parent. You must call removeView() on the child's parent first.
Solution:
Create a layout and add imageview in that xml.
inflate the xml and set that imageview in the alertdialog.
View dialoglayout = inflater.inflate(R.layout.scale_image, null);
ImageView view2 = (ImageView) dialoglayout.findViewById(R.id.enlargeImage);
view2.setImageBitmap(scaledBitmap);
alertdialog.setView(dialoglayout);
alertdialog.show();
Above piece of code solved my issue .
No comments:
Post a Comment