如何从URL图像到InfoWindowAdapter的Andr​​oid? [英] How to image from url into InfoWindowAdapter android?

查看:125
本文介绍了如何从URL图像到InfoWindowAdapter的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个InfoWindowAdapter显示来自一个URL的图像
 ,我有以下的code,但不显示我的图片

I'm trying to display an image from a url in a "InfoWindowAdapter" ,I have the following code, but does not show me the image

....
mMap = getMap();

mMap.setInfoWindowAdapter(new InfoWindowAdapter() {

  ...

 @Override
 public View getInfoContents(Marker marker) {

  View v = getActivity().getLayoutInflater().inflate(
R.layout.info_window_layout, null);

 String image_url = "http://api.androidhive.info/images/sample.jpg";
 new DownloadImageTask(imgEquipo).execute(image_url);
 return v;
 } 
});

调用的AsyncTask获取的图像

call to AsyncTask to get image

private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
    ImageView bmImage;

    public DownloadImageTask(ImageView bmImage) {
        this.bmImage = bmImage;
    }

    protected Bitmap doInBackground(String... urls) {
        String urldisplay = urls[0];
        Bitmap mIcon11 = null;
        try {
            InputStream in = new java.net.URL(urldisplay).openStream();
            mIcon11 = BitmapFactory.decodeStream(in);
        } catch (Exception e) {
            Log.e("Error", e.getMessage());
            e.printStackTrace();
        }
        return mIcon11;
    }

    protected void onPostExecute(Bitmap result) {
        bmImage.setImageBitmap(result);
    } }
 }

您的帮助tranks。

tranks for your help.

推荐答案

这是行不通的,因为你得到的图像之前返回的观点,他们不同步。

It won't work because the view is returned before you get the image, and they are not synchronized.

看看这种方式:

<一个href=\"http://stackoverflow.com/questions/14279442/i-my-using-google-mapv2-and-i-m-downloading-image-from-google-place-api-and-want\">I我使用谷歌mapV2而我会从谷歌的地方API下载图像,并希望在弹出

关键是你得到的图像后更新信息窗口。

The trick is to update the InfoWindow after you get the image.

这篇关于如何从URL图像到InfoWindowAdapter的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆