我創建了一個覆蓋圖,當我按下其中一個按鈕向我顯示一個帶有按鈕的對話框並且按下按鈕啓動另一個活動時,我需要因爲我嘗試了startActivity(意圖),但給我錯誤。如何從谷歌地圖警報對話框中啓動活動
公共類MiItemizedOverlay擴展ItemizedOverlay {
public MiItemizedOverlay(Context context, Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
this.context = context;
}
public void addLocalizacion(double lat, double lon, String etiqueta) {
int lt = (int) (lat * 1E6);
int ln = (int) (lon * 1E6);
punto = new GeoPoint(lt, ln);
OverlayItem item = new OverlayItem(punto, etiqueta, null);
mOverlays.add(item);
populate();
}
public void clear() {
mOverlays.clear();
populate();
}
@Override
protected OverlayItem createItem(int i) {
return mOverlays.get(i);
}
@Override
public int size() {
return mOverlays.size();
}
@Override
protected boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.setPositiveButton("Go", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(context, OtraActivity.class);
startActivity(intent);
}
}).create().show();
return true;
}
}
很難發現你的錯誤沒有logcat! – Gridtestmail