android – 显示从互联网下载的图像作为注释 – 使用毕加索

android – 显示从互联网下载的图像作为注释 – 使用毕加索,第1张

概述我无法显示从互联网下载的图像作为注释.我正在执行以下代码和毕加索图书馆.但是,如果我使用本地图像,它可以工作.提前感谢任何帮助. private void createAnnotation(int id, double lat, double lon, String caption, String photoUrl) { SKAnnotation annotation = new SKA 我无法显示从互联网下载的图像作为注释.我正在执行以下代码和毕加索图书馆.但是,如果我使用本地图像,它可以工作.提前感谢任何帮助.
private voID createAnnotation(int ID,double lat,double lon,String caption,String photoUrl) {    SKAnnotation annotation = new SKAnnotation(ID);    SKCoordinate coordinate = new SKCoordinate(lat,lon);    annotation.setLocation(coordinate);    annotation.setMininumZoomLevel(5);    SKAnnotationVIEw annotationVIEw = new SKAnnotationVIEw();    VIEw customVIEw =            (linearLayout) ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(                    R.layout.annotation_photo_and_text,null,false);    //  If wIDth and height of the vIEw  are not power of 2 the actual size of the image will be the next power of 2 of max(wIDth,height).    //annotationVIEw.setVIEw(findVIEwByID(R.ID.customVIEw));    TextVIEw tvCaption = (TextVIEw) customVIEw.findVIEwByID(R.ID.annotation_photo_caption);    tvCaption.setText(caption);    ImageVIEw ivPhoto = (ImageVIEw) customVIEw.findVIEwByID(R.ID.annotation_photo);    Picasso.with(getApplicationContext())            .load(photoUrl)            .resize(96,96)            //.centerCrop()            .into(ivPhoto);    //ivPhoto.setimageResource(R.drawable.hurricanerain);    annotationVIEw.setVIEw(customVIEw);    annotation.setAnnotationVIEw(annotationVIEw);    mapVIEw.addAnnotation(annotation,SKAnimationSettings.ANIMATION_NONE);}
解决方法 毕加索加载来自互联网的图像异步.尝试将图像下载到注释后再尝试添加.您可以使用目标来监听图像下载完成:
ImageVIEw ivPhoto = (ImageVIEw) customVIEw.findVIEwByID(R.ID.annotation_photo);  Target target = new Target() {      @OverrIDe    public voID onBitmapLoaded(Bitmap bitmap,Picasso.LoadedFrom from) {        ivPhoto.setimageBitmap(bitmap);        annotationVIEw.setVIEw(customVIEw);        annotation.setAnnotationVIEw(annotationVIEw);        mapVIEw.addAnnotation(annotation,SKAnimationSettings.ANIMATION_NONE);    }    @OverrIDe    public voID onBitmapFailed(Drawable errorDrawable) {}    @OverrIDe    public voID onPrepareLoad(Drawable placeHolderDrawable) {}};ivPhoto.setTag(target);Picasso.with(getApplicationContext())    .load(photoUrl)    .resize(96,96)    .into(target);
总结

以上是内存溢出为你收集整理的android – 显示从互联网下载的图像作为注释 – 使用毕加索全部内容,希望文章能够帮你解决android – 显示从互联网下载的图像作为注释 – 使用毕加索所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1133326.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存