Search code examples
androidandroid-progressbarpicasso

Show Progress while downloading image from server into imageview


I am ListView and would like to show progress, until image not downloaded from server into ImageView using Picasso library, still showing ic_launcher drawable while downloading image from server into ImageView, but what if i would like to show progress

    Picasso.with(context)
    .load(imageURL)
    .transform(transformation)
    .placeholder(R.drawable.ic_launcher)
    .error(R.drawable.ic_launcher)
    .into(viewHolder.imageView);

Solution

  • in your xml file you have to put progressbar above image, set visibility of progressbar visible and in your code

    Picasso.with(context)
           .load(file)
           .into(imageView, new Callback() {
               @Override
               public void onSuccess() {
                   progressbar.setVisibility(View.GONE);
               }
           });
    

    when image is download you have to setVisibility(View.GONE) to progressbar