Android studio 如何制作谷歌地图中的位置列表视图?
我是android开发的新手。目前我正在开发一个显示最近药店的应用程序 我成功地在地图上显示了它们,但我想制作活动半地图和半列表视图,列表视图应该让药店从最近的一家到最远的一家进行排序 这是我的MapActivity的xmlAndroid studio 如何制作谷歌地图中的位置列表视图?,android-studio,Android Studio,我是android开发的新手。目前我正在开发一个显示最近药店的应用程序 我成功地在地图上显示了它们,但我想制作活动半地图和半列表视图,列表视图应该让药店从最近的一家到最远的一家进行排序 这是我的MapActivity的xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapsActivity"
android:clickable="true"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical" >
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list">
</ListView>
</LinearLayout>
</LinearLayout>
this is the list item
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
tools:background="@android:color/white"
/>
这是列表项
我想在列表中显示我从地图上获得并排序的位置,但我不知道如何有一个非常有用的教程,我不久前学习过,特别是在标题“在ListView中显示位置”下,它可能会对您有所帮助。只要快速浏览一下您的代码,我认为您的MapActivity.xml中缺少了一个
元素,您的列表项需要一个布局
元素才能知道在哪里显示列表。看一下上面提到的教程,它给出了一些示例代码。希望有帮助