Home » Android » android – couldnt hide the progressbar after loading image in picasso?

android – couldnt hide the progressbar after loading image in picasso?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I was trying to integrate progress bar in ma app.but i couldn’t track the call back method.the progress bar always showing.how to hide when image is loded?

holder.imageView = (ImageView) localView.findViewById(R.id.imageView1);
holder.progressBar = (ProgressBar) localView.findViewWithTag(R.id.progressBar1);

localView.setTag(holder);
url = getItem(paramInt);
Picasso.with(getApplicationContext())
.load(url)
.placeholder(R.drawable.ic_launcher)
.error(R.drawable.ic_launcher)
.fit()
.into(holder.imageView, new Callback() {

    @Override
    public void onSuccess() {
        holder.imageView.setVisibility(View.VISIBLE);
        holder.progressBar.setVisibility(View.INVISIBLE);        
    }

    @Override
    public void onError() {
        holder.progressBar.setVisibility(View.VISIBLE);
        holder.imageView.setVisibility(View.INVISIBLE);
    }
});
How to&Answers:

Finally i fixed it.there was a bug in a Picasso 2.0.0 beta.used official library

Answer:

Try using VIEW.GONE instead of VIEW.INVISIBLE