开发者

Accessing an Android View from extended ItemizedOverlay?

I am creating an extension of ItemizedOverlay. When a user taps a pin on the map (onTap) I want to display a RelativeLayout, which is included in the same .xml file as the map. When the RelativeLayout is visable, it covers the map.

Since this view is the context for the main class, I do not know how to access the view (DetailLayout) from within the onTap() call.

<?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>
            <开发者_JS百科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>       


If your ItemizedOverlay is an inner class of your MapActivity, just call findViewById(). Here is a sample project from one of my books showing the sort of thing you are trying to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜