나는 방금 InfoWindow
을 다운로드하고 업데이트하는 것과 비슷한 문제를 겪어 왔으며 오늘 아침 벽에 머리를 대고 내 머리를 긁으면 나는이 작은 해결 방법을 제안했다. 이 하나.
내 AsyncTask
의 OnPostExecute()
방법에 marker.showInfoWindow()
를 호출 한 루프에서 끝나는 결코 제대로 내 변경 내용을 전파하지 된 InfoWindowAdapter
방법을 다시했다.
내가 사용한 솔루션은 현재 선택한 마커와 표시하고자하는 뷰를 저장하는 것이 었습니다. 나는 아래의 예제에서 TextView
이 DownloadBubbleInfo
AsyncTask
(내가 믿는 이미지 스레드와 비슷합니다)에서 업데이트되는 위치에 머물렀습니다.
// Setting a custom info window adapter for the google map
gMap.setInfoWindowAdapter(new InfoWindowAdapter() {
// Use default InfoWindow frame
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
public View getInfoContents(Marker arg0) {
if (selectedMarker.isInfoWindowShown()) {
return infoWindowView;
} else {
// Getting view from the layout file info_window_layout
infoWindowView = getLayoutInflater().inflate(
R.layout.bubblewindowlayout, null);
// Stash the base view in infoWindowView
// Getting reference to the TextView to set latitude
TextView tvTit = (TextView) infoWindowView
.findViewById(R.id.tv_title);
tvTit.setText("Fetching data...");
// Async the update so we're not slowed down waiting for
// the
// bubble to populate
new DownloadBubbleInfo(context, infoWindowView, arg0)
.execute(arg0.getTitle(), arg0.getSnippet());
// Returning the view containing InfoWindow contents
return infoWindowView;
}
}
});
gMap.setOnMarkerClickListener(new OnMarkerClickListener() {
public boolean onMarkerClick(Marker marker) {
// When a marker is clicked set it as the selected marker so
// we can track it for the InfoWindow adapter. This will
// make sure that the correct marker is still displayed when
// the callback from DownloadBubbleInfo is made to
// marker.showInfoWindow() which is needed to update the
// InfoWindow view.
selectedMarker = marker;
infoWindowView = null;
return false;
}
});
과의 관련 라인들 DownloadBubbleInfo
AsyncTask
:
이제
@Override
protected String[] doInBackground(String... queryparts) {
// Do the query and stash the results in queryResults and pass to
// onPostExecute to attach to the mainview (the current view from the
// main code) and then call showInfoWindow on the marker to re-launch
// the InfoWindowAdapter methods again to repopulate the InfoWindow view
// and attach it.
return queryResults;
}
protected void onPostExecute(String[] results) {
((TextView) mainview.findViewById(R.id.tv_title)).setText(results[0]);
((TextView) mainview.findViewById(R.id.tv_info)).setText(results[1]);
marker.showInfoWindow();
Log.i("Chris-Debug", "Reshowing InfoWindow");
}
,이 모든 헤이 프레스토 다른 코너를 올바른 마커가 당신의 AsyncTask
에서 반환 올바른 정보로 채워되고 있는지 확인해야하고 매우 어색한 Android Maps API 버전 인 GoogleMaps v2가 성공적으로 주최했습니다!
이 문제가 수정 되었습니까? 나는 같은 문제를 겪고있다 !! 어떤 도움을 주셔서 감사합니다! – LilMoke
전문 Android 개발자로서 해결책을 찾았습니까? :) 그것은 당신의 블로그에 있습니까? 거기에서 아무 것도 찾을 수 없기 때문에 : ( – glenneroo