day29高德地图的引用

高德
所有功能 官网都有解释
导入依赖

implementation 'com.amap.api:map2d:latest.integration'
implementation 'com.amap.api:search:latest.integration'

布局

<?xml version="1.0" encoding="utf-8"?>
<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"
    tools:context=".MainActivity"
    android:orientation="vertical">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/edit_bg"
        android:hint="我的位置"
        android:layout_marginTop="3dp"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="60dp"
        android:paddingLeft="5dp"
        android:id="@+id/my_location"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="2dp">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/edit_bg"
            android:hint="终点"
            android:layout_marginLeft="30dp"
            android:layout_marginTop="3dp"
            android:paddingLeft="5dp"
            android:layout_weight="1"
            android:id="@+id/my_destination"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="搜索"
            android:layout_weight="6"
            android:gravity="center"
            android:id="@+id/my_search"
            android:background="@drawable/txt_bg"
            android:layout_marginLeft="3dp"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="3dp">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="步行"
            android:padding="3dp"
            android:background="@drawable/txt_bg"
            android:layout_marginLeft="30dp"
            android:id="@+id/walk"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="驾车"
            android:padding="3dp"
            android:background="@drawable/txt_bg"
            android:id="@+id/driver"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="公交"
            android:padding="3dp"
            android:background="@drawable/txt_bg"
            android:id="@+id/bus"/>
    </LinearLayout>
    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:dividerHeight="3dp"
        android:divider="#B9B6B6"
        android:visibility="gone"
        android:id="@+id/my_list">

    </ListView>
    <com.amap.api.maps2d.MapView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/my_MapView">

    </com.amap.api.maps2d.MapView>


</LinearLayout>

list的Item布局

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

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/item_txt"
        android:textSize="18sp"/>

</LinearLayout>

适配器

public class MyListAdapter extends BaseAdapter {
   

    ArrayList<PoiItem> arrayList;
    Context context;

    public MyListAdapter(ArrayList<PoiItem> arrayList, Context context) {
   
        this.arrayList = arrayList;
        this.context = context;
    }

    @Override
    public int getCount() {
   
        return arrayList.size
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值