android - 在自定义对话框中显示 map

标签 android dictionary

我正在开发一个需要在对话框中显示 map 和一些细节的应用程序,为此我已经制作了自定义布局并使用了 map fragment 但是如何编写代码,意味着我对此一无所知,没有得到任何合适的教程或在对话框中显示 map 的示例。谁能给我一些教程或代码。提前致谢。

这是我的 custom_dialog.xml

<?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="wrap_content"
    android:background="@android:color/transparent" >

    <RelativeLayout
        android:id="@+id/relativeNavBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/pop_up_header" >

        <TextView
            android:id="@+id/EditItem_MapTxtName"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:textColor="@color/white"
            android:textSize="18sp" />
    </RelativeLayout>

    <LinearLayout
        android:id="@+id/relativeAutoComplete"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/relativeNavBar"
        android:layout_marginTop="20dp"
        android:orientation="vertical"
        android:paddingLeft="10dp"
        android:paddingRight="10dp" >

        <fragment
            android:id="@+id/map"
            android:name="com.google.android.gms.maps.MapFragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/EditItem_mapTxtDistance11"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_weight="0.25"
                android:text="@string/distance"
                android:textColor="@color/black"
                android:textSize="16sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/EditItem_mapTxtDistance"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_weight="0.75"
                android:ellipsize="end"
                android:singleLine="true"
                android:textColor="@color/greyish"
                android:textSize="14sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/EditItem_mapTxtAddress11"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_weight="0.25"
                android:text="@string/address"
                android:textColor="@color/black"
                android:textSize="16sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/EditItem_mapTxtAddress"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_weight="0.75"
                android:ellipsize="end"
                android:singleLine="true"
                android:textColor="@color/greyish"
                android:textSize="14sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/EditItem_mapTxtCity11"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_weight="0.25"
                android:text="@string/city"
                android:textColor="@color/black"
                android:textSize="16sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/EditItem_mapTxtCity"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_weight="0.75"
                android:ellipsize="end"
                android:singleLine="true"
                android:textColor="@color/greyish"
                android:textSize="14sp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="5dp"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/EditItem_mapTxtZip11"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_weight="0.25"
                android:text="@string/zip"
                android:textColor="@color/black"
                android:textSize="16sp"
                android:textStyle="bold" />

            <TextView
                android:id="@+id/EditItem_mapTxtZip"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:layout_weight="0.75"
                android:ellipsize="end"
                android:singleLine="true"
                android:textColor="@color/greyish"
                android:textSize="14sp" />
        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

最佳答案

您可以使用 DialogFragment 在对话框中显示 map ,这将在带有自定义布局的对话框中显示 map 。

查看 Tutorial

关于android - 在自定义对话框中显示 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20795863/

相关文章:

c - 没有线性搜索的 C 中的快速字典

Python3.4 : DataFrame from Dictionary

python - 为什么python字典占用这么多内存?

java - 如何阻止 Proguard 删除类型参数?

java - android 在没有任何收件人的情况下启动 SMS Intent

java - 安卓栈

android - 可滚动的 Recyclerview 水平和垂直景观

dictionary - 解析 tcl 中的文本文件并创建键值对字典,其中值采用列表格式

python - 将 python 输出格式化为 json

android - 为什么模拟器上不能上网,真机上却可以上网? (安卓工作室)