2

Android 플랫폼의 Google지도에서 내 아이콘에 대한 맞춤 툴팁을 만들려고합니다.Android : 맞춤 툴팁의 버튼 클릭 이벤트

나는 몇 가지 물건을 시도하고 이것이 내가 지금 가지고있는 것입니다.

의 Inflater 클래스 : 마커에

private class InfoHandler implements GoogleMap.InfoWindowAdapter, View.OnClickListener { 

    @Override 
    public View getInfoWindow(Marker marker) { 
     return null; 
    } 

    @Override 
    public View getInfoContents(Marker marker) { 
     View v = layoutInflater.inflate(R.layout.tooltip_brewer, null); 

     TextView tvLat = (TextView) v.findViewById(R.id.tv_title); 
     TextView tvLng = (TextView) v.findViewById(R.id.tv_snippet); 
     Button button = (Button) v.findViewById(R.id.btn_button); 
     tvLat.setText("TestTooltip"); 
     tvLng.setText("TestTooltip 1"); 
     button.setOnClickListener(this); 

     return v; 
    } 

    @Override 
    public void onClick(View view) { 
     Log.d(Constants.TAG, "Test 01"); 
    } 
} 

연결 :

public void setInfoWindow(LayoutInflater inflater) { 
     this.layoutInflater = inflater; 
     map.setInfoWindowAdapter(new InfoHandler()); 
    } 

툴팁 XML :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:gravity="center_vertical"> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginRight="10dp" 
    android:orientation="vertical"> 

    <TextView 
     android:id="@+id/tv_title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Title" 
     android:textSize="18sp" /> 

    <TextView 
     android:id="@+id/tv_snippet" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="snippet" /> 

</LinearLayout> 

<Button 
    android:id="@+id/btn_button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Button" /> 

</LinearLayout> 

지금 모든 작품은 내가 클릭 이벤트가 작업을 얻을 수 없습니다 을 받아 도구 설명의 버튼. 누군가가 그 해결책을 가지고 있습니까?

+1

가능한 중복 http://stackoverflow.com/questions/14123243/google- maps-api-v2-custom-infowindow-like-original-android-google-maps) – matiash

답변

3

라이브보기가 아니기 때문에 원하는 것을 할 수 없기 때문입니다.

참고 : 그려지는 정보창은 라이브보기가 아닙니다. 보기는 이 반환 된 시점에서 이미지로 렌더링 된 입니다 (View.draw (Canvas) 사용). 즉, 이후의보기 변경은 이지도의 정보 창에 반영되지 않습니다. 나중에 이미지 창이로드 된 후 정보 창을 업데이트하려면 showInfoWindow()를 호출하십시오. 또한 정보 창은 터치 또는 제스처 이벤트와 같은 일반적인보기에 일반적으로 나타나는 대화 형 기능 중 하나 인 을 존중하지 않습니다. 그러나 은 전체 정보창의 일반 클릭 이벤트를 아래 섹션에서 설명하는 으로 수신 할 수 있습니다. 문서에서

보기

https://developers.google.com/maps/documentation/android/infowindows

[원래 안드로이드 구글지도처럼 구글지도 API v2를 사용자 정의 정보창 (의