1

警告: Noob アラート。

私は Android と OSM の両方に非常に慣れていません。私が欲しいのは、表示するマップだけです。

Google の MapView を main.xml のルートにできますが、OSM の MapView もルートにできますか?

これが私の現在のmain.xmlです:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<org.osmdroid.views.MapView
    android:id="@+id/map"
    android:layout_width="fill_parent"
    android:layout_height="0dip"
    android:layout_weight="1"
    tilesource="MapquestOSM" />

</LinearLayout>

ここに私の活動があります:

public class AndroidManiTestActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.id.map);
    }
}

次のエラーが表示されます。

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.anny/com.anny.AndroidManiTestActivity}: 

Android.content.res.Resources$NotFoundException: Resource ID #0x7f050000 type #0x12 is not valid

編集: osmdroid 3.0.8 と slf4j 1.5.8 を実行しています。

4

1 に答える 1

2

setContentView(.. ) は .id ではなく .layout 引数を取る必要があるため、

setContentView(R.layout.main);

その後、次のような行で .map を参照できます。

findViewById(R.id.map);
于 2012-05-09T18:33:43.497 に答える