Progressbar Loading Picasso in Android

In layout XML insert code:

<ProgressBar
    android:visibility="gone"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/progressBar"
    style="?attr/progressBarStyle"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"/>

In MainActivity insert code for Picasso:

protected void loadImage(String CurrentUrl,ImageView imageView){
    progressBar.setVisibility(View.VISIBLE);
    Picasso.with(this)
            .load(subCurrentUrl)
            .resize(width,height)
            .into(imageView, new Callback() {
                @Override
                public void onSuccess() {
                    progressBar.setVisibility(View.GONE);
                }

                @Override
                public void onError() {

                }
            });
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s