我有一个异步方法,可以将标记放在Google Map View上。在下面的代码中,我试图将对象overlayitem传递给onProgressUpdate方法。我收到一个编译器错误,itemizedOverlay.addOverlay不期望一个数组。我很困惑为什么将overlayitem作为数组传递(即overlayitem [])。有人可以帮忙吗?
class OverlayLoader extends AsyncTask<Void, OverlayItem, Void> {
List<Overlay> mapOverlays;
@Override
protected void onPreExecute() {
mapOverlays = mapView.getOverlays();
}
@Override
protected Void doInBackground(Void... params) {
SQLiteDatabase db = mDbHelper.getReadableDatabase();
Cursor mCursor = db.query(TABLE_NAME, null, null, null, null, null, null);
startManagingCursor(mCursor);
OverlayItem overlayitem = null;
while (mCursor.moveToNext()) {
Address = mCursor.getString(4);
Name = mCursor.getString(0);
String noSpaces = Address.replaceAll(" ", "+");
JSONObject geocoded = getLocationInfo(noSpaces);
GeoPoint point = getGeoPoint(geocoded);
overlayitem = new OverlayItem(point, Name, Address);
publishProgress(overlayitem);
}
return null;
}
protected void onProgressUpdate(OverlayItem... overlayitem) {
List<Overlay> mapOverlays = mapView.getOverlays();
String x = "@Hello";
Log.e("Hello",""+x);
Drawable drawable = maptabview.this.getResources().getDrawable(R.drawable.pushpin);
CustomizedItemOverlay itemizedOverlay =
new CustomizedItemOverlay(drawable, maptabview.this);
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
}
}
答案 0 :(得分:1)