【发布时间】:2017-01-12 19:41:51
【问题描述】:
我正在尝试使用 Retrofit 2.1.0 从 1.9.0 升级 在响应中我无法运行我想在地图上放置的标记。 在 Retrofit 1.9.0 上它运行良好,但想要使用更新的系统。
Retrofit adapter = new Retrofit.Builder()
.baseUrl( AppConfig.URL_PINS )
.addConverterFactory(GsonConverterFactory.create())
.build();
MapPinsApiInterface pinsApiInterface = adapter.create(MapPinsApiInterface.class);
Call<List<MapPins>> pins = (Call<List<MapPins>>) pinsApiInterface.getStreams();
pins.enqueue(new Callback<List<MapPins>>() {
@Override
public void onResponse(Call<List<MapPins>> pins, Response<List<MapPins>> response) {
if (!isAdded() || pins == null )
return;
int numMarkersInRainbow[] = {
R.mipmap.homecenter,
R.mipmap.shop,
R.mipmap.marksilv,
R.mipmap.markgold,
R.mipmap.markgreen,
R.mipmap.markoran,
R.mipmap.itsyou,
R.mipmap.no_gps
};
bounds = new LatLngBounds.Builder();
for (MapPins pin : pins) { <***** Here is my error ***>
MarkerOptions options = new MarkerOptions().position(new LatLng(pin.getLatitude(), pin.getLongitude()));
options.title(pin.getName());
options.snippet(pin.getDepth());
options.icon(BitmapDescriptorFactory.fromResource(numMarkersInRainbow[pin.getMarker()]));
Marker mkr = googleMap.addMarker(options);
mMarkers.put(mkr.getId(), pin.getSiteid());
bounds.include(new LatLng(pin.getLatitude(), pin.getLongitude()));
}
}
在线:(MapPins pin : pins) {
我收到一个错误
对于每个不适用于类型“retrofit2.call”
我确定我忽略了一些东西。我错过了什么?
【问题讨论】:
标签: java list foreach retrofit2