首页 > 代码库 > picasso设置背景图片

picasso设置背景图片

compile‘com.squareup.picasso:picasso:2.5.2‘

  String url = "http://192.168.191.1:8080/b"+(i+1)+".jpg";
            image = new ImageView(context);
//            Picasso.with(context).load(url).into(image);

            Picasso.with(context).load(url).into(new Target() {
                @Override
                public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                    image.setBackground(new BitmapDrawable(getResources(),bitmap));
                }

                @Override
                public void onBitmapFailed(Drawable errorDrawable) {
                    Log.e("MainActivity","-----------onBitmapFailed--------------");
                }

                @Override
                public void onPrepareLoad(Drawable placeHolderDrawable) {
                    Log.e("MainActivity","-----------onPrepareLoad--------------");
                }
            });

 

picasso设置背景图片