私はgooglemapを使っています。カスタムマーカーウィンドウを実装しました。このウィンドウにはマーカーの写真が含まれています。私は文字列として写真のURLを取って、スレッドでイメージビューに設定しています。ただし、コードはユーザーと同期されません。マーカーをクリックすると、クリックした前のマーカーの写真が表示されます。私がデバッグしたとき、私は本当のURLの値が背景から来ているのを見ることができますが、imageview操作への設定イメージは遅くなっています。どうすればこの問題を解決できますか?私はピカソと滑空を試みましたが、それと同じ問題です。バックグラウンド操作で画像ビューを設定しようとしています
@Override
public void onMapReady(GoogleMap map) {
this.Window = (ViewGroup) getLayoutInflater().inflate(R.layout.marker_window, null);
this.imageview = (ImageView) Window.findViewById(R.id.marker_photo);
googleMap = map;
googleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(final Marker marker) {
createThread(imageview,URL).start();
mapWrapperLayout.setMarkerWithInfoWindow(marker, infoWindow);
return infoWindow;
}
return null;}
});
}
private synchronized Thread createThread(final ImageView imageView, final String URL)
{
Thread thread=new Thread(new Runnable() {
@Override
public void run() {
download_image(URL,imageView);
}
});
return thread;
}
public void download_image(String url,ImageView imageview) {
URL newurl = null;
try {
newurl = new URL(url);
} catch (MalformedURLException e) {
e.printStackTrace();
}
Bitmap bitmap = null;
try {
bitmap= BitmapFactory.decodeStream(newurl.openConnection().getInputStream());
} catch (Exception e) {
e.printStackTrace();
}
imageview.setImageBitmap(bitmap);
}