Google Maps Version 2 - Updating information windows

不问归期 提交于 2019-12-12 04:57:10

问题


As we know in google maps android version 2, a custom information windows, is a view that converts to an image. Actually google aftre you return you view converts the view to a image an then show it to the info windows.

But I want to show images downloading from internet to my infowindow. Actually, I want that before that download complete show an progress bar to my infowindows and after it compeleted update info windows, by this mechanism how I can do this?


回答1:


  • Have a model object that contains int for progress and Bitmap for actual image.
  • Start some kind of background operation started (e.g. AsyncTask) to download image.
  • Update model's progress from AsyncTask.onProgressUpdate.
  • Update model's image from AsyncTask.onPostExecute.
  • Have an observer for model (see Observer partern).
  • If you keep AsyncTask (or any other kind of Thread in Activity context, don't forget to cancel it and you may also skip observer pattern.
  • Save reference to marker showing info window inside InfoWindowAdapter.getInfoWindow. Call it markerShowingInfoWindow.
  • When you are notified of progress update,

call:

if (markerShowingInfoWindow != null && markerShowingInfoWindow.isShowingInfoWindow()) {
    markerShowingInfoWindow.showInfoWindow();
}

To force InfoWindowAdapter.getInfoWindow call and create ViewGroup containing ProgressBar and ImageView from progress and image values inside model.

As always, translate this into C# world.



来源:https://stackoverflow.com/questions/17131039/google-maps-version-2-updating-information-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!