1

座標が保存されたデータベースがあり、これらを読み取ってマップに自動的に入力したいと考えています。私はいくつかの試みを試みましたが、これを機能させることができないようです。これが私のコードです:

public class allmapactivity extends MapActivity {
MapController mControl;
GeoPoint GeoP;
MapView mapV;
private SQLiteAdapter mySQLiteAdapter;
Cursor cursor;

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.map);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);


    mapV = (MapView) findViewById(R.id.mapview);
    mapV.displayZoomControls(true);
    mapV.setBuiltInZoomControls(true);
    mapV.setSatellite(false);

    List<Overlay> mapOverlays = mapV.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.pin);
    HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable, this);

    cursor = mySQLiteAdapter.queueAll5();
    cursor.moveToFirst();

    while (cursor.isAfterLast() == false) {
        GeoPoint point = new GeoPoint((int) (cursor.getInt(cursor.getColumnIndex(SQLiteAdapter.KEY_CONTENT11))*1E6), (int) (cursor.getInt(cursor.getColumnIndex(SQLiteAdapter.KEY_CONTENT12))*1E6));
        OverlayItem overlayitem = new OverlayItem(point, "Test", "Test");
        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);
    cursor.moveToNext();
}



}


@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}

なぜこれがうまくいかないのか、誰にでも教えていただければ幸いです。PSここにlogcatがあります:

07-19 07:27:14.193: E/AndroidRuntime(531): FATAL EXCEPTION: main
07-19 07:27:14.193: E/AndroidRuntime(531): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.inh.mapbud/com.inh.mapbud.allmapactivity}: java.lang.NullPointerException
07-19 07:27:14.193: E/AndroidRuntime(531):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-19 07:27:14.193: E/AndroidRuntime(531):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-19 07:27:14.193: E/AndroidRuntime(531):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-19 07:27:14.193: E/AndroidRuntime(531):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-19 07:27:14.193: E/AndroidRuntime(531):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-19 07:27:14.193: E/AndroidRuntime(531):  at android.os.Looper.loop(Looper.java:130)
07-19 07:27:14.193: E/AndroidRuntime(531):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-19 07:27:14.193: E/AndroidRuntime(531):  at java.lang.reflect.Method.invokeNative(Native Method)
07-19 07:27:14.193: E/AndroidRuntime(531):  at java.lang.reflect.Method.invoke(Method.java:507)
07-19 07:27:14.193: E/AndroidRuntime(531):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-19 07:27:14.193: E/AndroidRuntime(531):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-19 07:27:14.193: E/AndroidRuntime(531):  at dalvik.system.NativeStart.main(Native Method)
07-19 07:27:14.193: E/AndroidRuntime(531): Caused by: java.lang.NullPointerException
07-19 07:27:14.193: E/AndroidRuntime(531):  at com.inh.mapbud.allmapactivity.onCreate(allmapactivity.java:45)
07-19 07:27:14.193: E/AndroidRuntime(531):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-19 07:27:14.193: E/AndroidRuntime(531):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-19 07:27:14.193: E/AndroidRuntime(531):  ... 11 more
4

2 に答える 2

0

allmapactivity アクティビティの 45 行目を確認します。

于 2012-07-19T07:38:05.277 に答える