1
我按照這個教程:http://developer.android.com/resources/tutorials/views/hello-mapview.html 它運行正常,除非我點擊我的圖標在地圖上,對話框沒有出現。應用程序停止。還有其他人遇到過類似的問題嗎?目標平臺android vs谷歌api
我不知道google api是什麼;有人可以向我解釋嗎?這是否意味着上述教程中的代碼不會在android手機上運行?
這裏是我的代碼:
package com.example.hellogooglemaps;
import java.util.List;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
public class Hellogooglemaps extends MapActivity {
/*Called to say that we are not displaying any route information*/
@Override
protected boolean isRouteDisplayed() {
return false;
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.icon);
HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);
GeoPoint point = new GeoPoint(19240000,-99120000);
OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!", "I'm in Mexico City!");
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}
}
感謝您的評論。我將代碼添加到了我的請求中。希望這可以幫助。你能告訴我我做錯了什麼嗎? – Sean 2010-09-19 21:29:57
你可以在應用程序崩潰後粘貼logcat嗎? – Cristian 2010-09-19 23:36:32