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