自定义信息窗口适配器与地图 v2 中的自定义数据 [英] custom info window adapter with custom data in map v2

查看:33
本文介绍了自定义信息窗口适配器与地图 v2 中的自定义数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 android 的地图 v2 中制作自定义信息窗口适配器,如下所示.

I want to make custom info window adapter in map v2 in android as like below.

我已经看到下面的链接,但没有得到更多.

I have seen below link but doesn't get more.

1,2,3,

以下是我的内容布局文件.

below is my content layout file.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
>
    <ImageView
        android:id="@+id/infocontent_iv_image"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_alignParentTop="true" 
    />
    <RelativeLayout
        android:id="@+id/infocontent_rl_middle"
        android:layout_below="@id/infocontent_iv_image"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        android:layout_margin="5dp"
    >

    </RelativeLayout>
    <TextView
        android:id="@+id/infocontent_tv_name"
        android:layout_below="@id/infocontent_rl_middle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textStyle="bold" 
        android:layout_margin="5dp"
    />
    <TextView
        android:id="@+id/infocontent_tv_type"
        android:layout_below="@id/infocontent_tv_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textColor="#CCCCCC"
        android:layout_margin="5dp"
    />
    <TextView
        android:id="@+id/infocontent_tv_desc"
        android:layout_below="@id/infocontent_tv_type"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
    />
    <TextView
        android:id="@+id/infocontent_tv_addr"
        android:layout_below="@id/infocontent_tv_desc"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
    />
</RelativeLayout>

那么有人帮助我如何将数据设置为信息窗口适配器中的所有视图?

So any one help me how can i set data to all views in infowindow adapter?

推荐答案

I have open dialog onMarker() 点击.和 setContentView(my layout).

I have open dialog onMarker() click. and setContentView(my layout).

我使用了以下代码.

@Override
    public boolean onMarkerClick(Marker arg0) {
        if(arg0.getSnippet() == null){
            mMap.moveCamera(CameraUpdateFactory.zoomIn());
            return true;
        }
        //arg0.showInfoWindow();
        final DataClass data = myMapData.get(arg0);
        final Dialog d = new Dialog(MainActivity.this);
        d.requestWindowFeature(Window.FEATURE_NO_TITLE);
        //d.setTitle("Select");
        d.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
        d.setContentView(R.layout.info_content);
        ivPhoto = (ImageView)d.findViewById(R.id.infocontent_iv_image);
        AddImageOnWindow executeDownload = new AddImageOnWindow();
        final LatLng l = arg0.getPosition();
        executeDownload.execute(l);
        TextView tvName = (TextView)d.findViewById(R.id.infocontent_tv_name);
        tvName.setText(data.getPlaceName());

        TextView tvType = (TextView)d.findViewById(R.id.infocontent_tv_type);
        tvType.setText("("+data.getPlaceType()+")");

        TextView tvDesc = (TextView)d.findViewById(R.id.infocontent_tv_desc);
        tvDesc.setText(data.getPlaceDesc());

        TextView tvAddr = (TextView)d.findViewById(R.id.infocontent_tv_addr);
        tvAddr.setText(Html.fromHtml(data.getPlaceAddr()));

d.show();
return true;

这篇关于自定义信息窗口适配器与地图 v2 中的自定义数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆