Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从ExtendedItemizeOverlay访问Android视图?_Android_Google Maps - Fatal编程技术网

从ExtendedItemizeOverlay访问Android视图?

从ExtendedItemizeOverlay访问Android视图?,android,google-maps,Android,Google Maps,我正在创建ItemizeOverlay的扩展。当用户点击地图上的pin(onTap)时,我想显示一个RelativeLayout,它与地图包含在同一个.xml文件中。当相对物可见时,它会覆盖地图 因为这个视图是主类的上下文,所以我不知道如何从onTap()调用中访问视图(DetailLayout) 如果您的ItemizedOverlay是MapActivity的内部类,只需调用findViewById()。从我的一本书中可以看出您正在尝试做的事情。目前,我还没有将其列为MapActivty的

我正在创建ItemizeOverlay的扩展。当用户点击地图上的pin(onTap)时,我想显示一个RelativeLayout,它与地图包含在同一个.xml文件中。当相对物可见时,它会覆盖地图

因为这个视图是主类的上下文,所以我不知道如何从onTap()调用中访问视图(DetailLayout)



如果您的
ItemizedOverlay
MapActivity
的内部类,只需调用
findViewById()
。从我的一本书中可以看出您正在尝试做的事情。

目前,我还没有将其列为MapActivty的内部类。。。我可以四处走动,但我会看看还能做些什么。现在,我可以通过日志(“此处详细信息。此处详细信息”)读取默认的文本视图文本,但我无法在屏幕上显示视图,因为它说“addView”在ItemizeOverlay中无法识别。@Chris:“目前,我没有将ItemizeOverlay作为MapActivty的内部类”--您还可以将
MapActivity
作为
ItemizeOverlay
的构造函数参数传递。“但是我无法在屏幕上显示视图,因为它说ItemizeOverlay中无法识别“addView”。——正确。您不想将其添加到覆盖中。您希望将其添加到
MapActivity
中提供给
setContentView()
的内容中。或者,让它一直在那里,并根据需要在可见和消失之间切换。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"    
android:id="@+id/mainlayout"    
android:orientation="vertical"    
android:layout_width="fill_parent"    
android:layout_height="fill_parent" >

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="MY KEY HERE"
    />    



    <RelativeLayout 
        android:id="@+id/DetailLayout" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"  
        android:gravity="left"
        xmlns:android="http://schemas.android.com/apk/res/android">
            <LinearLayout
                android:id="@+id/DetailCloseButtonLayout"
                android:layout_width="fill_parent" 
                android:layout_height="36dp" 
                android:gravity="center_vertical|right"
                xmlns:android="http://schemas.android.com/apk/res/android">
                <Button       
                    android:id="@+id/DetailCloseButton"     
                    android:background="@drawable/close"  
                    android:layout_width="15dp"        
                    android:layout_height="15dp"
                    android:layout_marginRight="10dp" 
                    android:gravity="center_vertical">
                </Button>
            </LinearLayout>
            <TextView 
                android:text="Detail Here. Detail Here." 
                android:id="@+id/DetailTextView" 
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content"
                android:layout_below="@id/DetailCloseButtonLayout">
            </TextView>

    </RelativeLayout>