Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 显示从互联网下载的图像作为注释 – 使用毕加索大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我无显示从互联网下载的图像作为注释.我正在执行以下代码和毕加索图书馆.但是,如果我使用本地图像,它可以工作.提前感谢任何帮助.
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);
}

解决方法@H_801_6@
毕加索加载来自互联网的图像异步.尝试将图像下载到注释后再尝试添加.您可以使用目标来监听图像下载完成:
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 – 显示从互联网下载的图像作为注释 – 使用毕加索所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。