Android GoogleMap 2通过通用图像加载器在InfoWindow中使用ImageViewdynamic更新信息

我正在研究新的Google Map v2 API。

我已经使用ImageLoader在标记上dynamic显示图像。

但问题是,当我已经onLoadingComplete()的通用图像加载器,ImageView不是既不自动也不手动失效。

下一次,如果我点击相同的标记,将从通用图像加载程序的caching中显示图像。

以下是我的CustomInfoWindowAdapter代码:

private class CustomInfoWindowAdapter implements InfoWindowAdapter { @Override public View getInfoContents(Marker marker) { return null; } @Override public View getInfoWindow(Marker marker) { final View mWindow = getLayoutInflater().inflate(R.layout.custom_info_window, null); render(marker, mWindow); return mWindow; } private void render(final Marker marker, View view) { final String url = markers.get(marker.getId()).getStrProfilePic(); final ImageView image = ((ImageView) view.findViewById(R.id.badge)); Log.e(TAG, "URL : " + url); if ( url != null && !url.equalsIgnoreCase("null") && !url.equalsIgnoreCase("")) { imageLoader.displayImage(url, image, options, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); ((ImageView) view).invalidate(); } }); } else { image.setImageResource(R.drawable.noimage); } final String title = marker.getTitle(); final TextView titleUi = ((TextView) view.findViewById(R.id.title)); if (title != null) { titleUi.setText(title); } else { titleUi.setText(""); } final String snippet = marker.getSnippet(); final TextView snippetUi = ((TextView) view.findViewById(R.id.snippet)); if (snippet != null) { snippetUi.setText(snippet); } else { snippetUi.setText(""); } } } 

当我添加标记时,我将标记ID存储在HashTable中。 从他们我会得到照片的url。

Solutions Collecting From Web of "Android GoogleMap 2通过通用图像加载器在InfoWindow中使用ImageViewdynamic更新信息"

我在课堂上采取了一个标记对象,并使用该对象来更新标记信息。

我已经定制我的类如下更新ImageView:

 private class CustomInfoWindowAdapter implements InfoWindowAdapter { private View view; public CustomInfoWindowAdapter() { view = getLayoutInflater().inflate(R.layout.custom_info_window, null); } @Override public View getInfoContents(Marker marker) { if ( YourClassName.this.marker != null && ClassName.this.marker.isInfoWindowShown() ) { YourClassName.this.marker.hideInfoWindow(); YourClassName.this.marker.showInfoWindow(); } return null; } @Override public View getInfoWindow(final Marker marker) { YourClassName.this.marker = marker; final String url = markers.get(marker.getId()).getStrProfilePic(); final ImageView image = ((ImageView) view.findViewById(R.id.badge)); if ( url != null && !url.equalsIgnoreCase("null") && !url.equalsIgnoreCase("")) { imageLoader.displayImage(url, image, options, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); getInfoContents(marker); } }); } else { image.setImageResource(R.drawable.noimage); } final String title = marker.getTitle(); final TextView titleUi = ((TextView) view.findViewById(R.id.title)); if (title != null) { titleUi.setText(title); } else { titleUi.setText(""); } final String snippet = marker.getSnippet(); final TextView snippetUi = ((TextView) view.findViewById(R.id.snippet)); if (snippet != null) { snippetUi.setText(snippet); } else { snippetUi.setText(""); } return view; } } 

检查示例

从信息窗口callback返回的查看不能更新之后。

尝试遵循以下build议: Maps V2 InfoWindow中的dynamic内容