0

I have a NetworkImageView which has to show image once I click a button. When I click the button for the first time it doesn't display the image but if I click it second time then its showing the image.

I have set default image for it and it shows that image for first click of button but if I click it again then it shows the image form the url.

ImageLoader imageLoader = mInstance.getImageLoader();
imageLoader.get(url, ImageLoader.getImageListener(img, R.drawable.placeholder, android.R.drawable.ic_dialog_alert));
img.setImageUrl(url, mInstance.getImageLoader());
Yurets
  • 3,999
  • 17
  • 54
  • 74
vishal gaurav
  • 686
  • 1
  • 9
  • 24
  • 2
    Possible duplicate of [How to download an Image by using Volley?](https://stackoverflow.com/questions/41104831/how-to-download-an-image-by-using-volley) – kandroidj Jul 03 '18 at 13:40
  • @inner_class7 I don't know how it's a duplicate question, I am not asking about the way to download image using volley, I just wanted to know, what could be the reason for this behavior of NetworkImageView. If you can't help or can't understand my question don't simply tag it as a duplicate question. – vishal gaurav Jul 03 '18 at 18:27
  • Can you add the relevant parts of activity? Like the part of setting onClickListener to button, which url is used. – rushi Jul 03 '18 at 19:17

1 Answers1

-2

Is the use of NetworkImageView mandatory? If not, you should try using Picasso library: http://square.github.io/picasso/ . It's super easy to use!

Answering your question using picasso:

You can use a normal ImageView, then, onClick you fetch the image you want, nad inflate your view with the following method:

Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView);
Daniel Beleza
  • 389
  • 1
  • 15
  • OP doesn't ask for _how_ to load image from network. This doesn't answer _why_ OP's method doesn't work in manner s/he described. – rushi Jul 03 '18 at 19:15