I’m trying to download an image, and create an ImageView dynamically and add it to my layout, but it won’t display the image. Here is my code:
ImageView image = new ImageView(this);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
image.setLayoutParams(vp);
image.setScaleType(ImageView.ScaleType.CENTER_CROP);
image.setMaxHeight(50);
image.setMaxWidth(50);
image.setImageDrawable(avatar);
theLayout.addView(image);
maybe I need to refresh the layout after I add the ImageView? How do you “refresh”?
Try the following code, and you will not need to refresh. Put your image url into the
inputurlvariable.