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 – 显示从互联网下载的图像作为注释 – 使用毕加索所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)