Android プログラミングを発見しましたが、次のエラーに直面しています: textview は org.mapsforge.android.maps.MapView にキャストできません。
次のコマンドは、このエラーを生成しています:
this.vuemap = (MapView) findViewById(R.id.vuemap);
私のmainscreen.xmlは次のとおりです:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainView"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/trtext"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#47FFFFFF"
android:gravity="right"
android:text="0"
android:textSize="50dp">
</TextView>
<TextView
android:id="@+id/tltext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#47000000"
android:text="0"
android:textSize="50dp" >
</TextView>
<org.mapsforge.android.maps.MapView
android:id="@+id/vuemap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" >
</org.mapsforge.android.maps.MapView>
</RelativeLayout>`
非常に奇妙なのは、レイアウトで textview/mapview の位置を反転させても、問題がなくなることです。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainView"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<org.mapsforge.android.maps.MapView
android:id="@+id/vuemap"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" >
</org.mapsforge.android.maps.MapView>
<TextView
android:id="@+id/trtext"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#47FFFFFF"
android:gravity="right"
android:text="0"
android:textSize="50dp">
</TextView>
<TextView
android:id="@+id/tltext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#47000000"
android:text="0"
android:textSize="50dp" >
</TextView>
</RelativeLayout>`