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--------------");
                }
            });

 

posted @ 2017-02-11 22:11  次序  阅读(1227)  评论(0编辑  收藏  举报