MapsViewを実装するアプリを作成しました。マーカーをクリックすると、picassoを使用してデータベースからデータを取得する情報ウィンドウが表示されます。それは正常に動作しますが、問題は、情報ウィンドウの画像が私に必要な画像を表示しないことです。それでもプレースホルダー画像が表示されます。しかし、地図をクリックしてマーカーをもう一度クリックすると、必要な画像が表示されます。しかし、地図をクリックしていない(まだマーカーをクリックしていない)場合は、プレースホルダーマーカーが表示されます。必要な画像を表示するには(プレースホルダ画像が必要な画像に置き換わります)、時間を教えてください。ピカソ付きGoogleマップでinfoWindowで画像を取得する方法 - Android
ここに私のコードは
public void plotMarkers(ArrayList<MyMarker> markers) {
if(markers.size() > 0) {
for (MyMarker myMarker : markers)
{
dest = new LatLng(myMarker.getmLatitude(), myMarker.getmLongitude());
markerOption = new MarkerOptions().position(dest);
location_marker = mMap.addMarker(markerOption);
Target target = new PicassoMarker(location_marker);
targets.add(target);
ImageView image = new ImageView(this);
image.setImageResource(R.mipmap.marker);
int width = image.getDrawable().getIntrinsicWidth();
int height = image.getDrawable().getIntrinsicHeight();
Picasso.with(MapsActivity.this).load(myMarker.getmIcon()).resize(width, height).onlyScaleDown().into(target);
mMarkersHashMap.put(location_marker, myMarker);
i = getIntent();
if(i.getBooleanExtra("maps", true)) {
location_marker.setTitle(i.getStringExtra("nama"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(dest, 16));
}
else {
mMap.setInfoWindowAdapter(new MarkerInfoWindowAdapter());
}
}
}
}
public class MarkerInfoWindowAdapter implements GoogleMap.InfoWindowAdapter
{
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
View v = getLayoutInflater().inflate(R.layout.info_windowlayout, null);
MyMarker myMarker = mMarkersHashMap.get(marker);
TextView markerLabel = (TextView) v.findViewById(R.id.marker_label);
markerLabel.setText(myMarker.getmLabel());
ImageView foto = (ImageView) v.findViewById(R.id.foto);
Picasso.with(getApplicationContext()).load(myMarker.getmImage()).placeholder(R.layout.progress).error(R.mipmap.error).into(foto);
TextView anotherLabel = (TextView) v.findViewById(R.id.another_label);
anotherLabel.setText("Baca selengkapnya...");
return v;
}
}
あなたは[ここ](https://stackoverflow.com/questions/24528482/image-not-loading-from-url-in-custom-infowindow-using-picasso-image-loading-libr)への回答があります。 。 これは素晴らしい解決策ではありませんが、機能します。 –