J'essaie d'utiliser un MapView
en conjonction avec un ListView
. Ma compréhension est que j'ai besoin d'étendre MapActivity
, puis obtenir une référence à la ListView
à utiliser dans ma classe. Mon problème est que je ne peux pas obtenir une référence à la ListView
.Android: Comment faire référence à listView?
Ceci est mon XML:
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/AbsoluteLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_y="0dp"
android:clickable="true" />
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="268dp"
android:layout_y="151dp" >
</ListView>
</AbsoluteLayout>
Voilà comment je suis en train de faire une référence à la ListView
:
//instance vars
ListView listView;
//get ref to listview
listView = findViewById(R.id.list);
Pour une raison quelconque, il est dit que la liste n'est pas un champ. Est-ce que je le mentionne incorrectement?
Toute aide appréciée.
'AbsoluteLayout' est obsolète :) – Geros