8

클릭 빈 InfoWindow는 : 내 titlesnippet 영어에있을 때마커이 내 GoogleMap으로 새로운 마커를 추가하려면 코드입니다

MarkerOptions m = new MarkerOptions(); 
m.title(title); 
m.snippet(snippet); 
m.position(location); 
mMap.addMarker(m); 

mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { 
     @Override 
     public void onInfoWindowClick(Marker marker) { 
      Toast.makeText(DemoActivity.this, "WindowClicked: "+ marker.getTitle() + ":" + marker.getSnippet(), 
        Toast.LENGTH_SHORT).show(); 
     } 
    }); 

지금이 잘 작동합니다. infoWindowToast은 예상대로 작동합니다.

하지만, 내 경우처럼, titlesnippet 아랍어에의 Toast 잘 작동하지만 정보창은 빈 창을 보여줍니다.

아랍어와 관련된 버그가 마음에들 것 같습니다. 이 문제를 해결할 방법이 있습니까?

답변

6

이 문제를 해결하려면 맞춤 정보 창을 표시하는 것이 좋습니다. InfoWindowAdapter을 만들고 GoogleMap.setInfoWindowAdapter()으로 설정하면됩니다.

기본 정보 창을 바꾸려면 getInfoWindow (Marker)를 사용자 정의 렌더링으로 대체하고 getInfoContents (Marker)에 대해 null을 반환하십시오. 기본 정보 창 프레임 (설명 선 거품) 내 정보창 내용 만 바꾸려면 getInfoWindow (Marker)에서 null을 반환하고 대신 getInfoContents (Marker)를 재정의하십시오.

더 많은 정보 : https://developers.google.com/maps/documentation/android/marker#info_windows

+0

완벽하게 작동합니다. 감사! – iTurki

+0

@iturki 이것은 내 문제를 해결하지 못했습니다. 나는 아랍어를 사용할 때 여전히 빈 창이있다. 문제를 해결하기 위해 정확히 무엇을 했습니까?> – AlAsiri

+0

@AlAsiri 내 대답보기. – iTurki

7

@jimmithy의 대답은 내 질문을 해결했다.

이 그냥 세 단계로 구현 this project에서 그것의입니다 :

1 단계 : 당신의 정보창의 레이아웃을 만듭니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal"> 

<ImageView 
android:id="@+id/icon" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_gravity="center_vertical" 
android:padding="2dip" 
android:src="@drawable/ic_launcher" 
android:contentDescription="@string/icon"/> 

<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 

<TextView 
android:id="@+id/title" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:textSize="25sp" 
android:textStyle="bold"/> 

<TextView 
android:id="@+id/snippet" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:textSize="15sp"/> 
</LinearLayout> 

</LinearLayout> 

2 단계 :이 InfoWindowAdapter의 구현을 만들고 여기에 popup.xml 코드입니다.

class PopupAdapter implements InfoWindowAdapter { 
    LayoutInflater inflater=null; 

    PopupAdapter(LayoutInflater inflater) { 
    this.inflater=inflater; 
    } 

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

    @Override 
    public View getInfoContents(Marker marker) { 
    View popup=inflater.inflate(R.layout.popup, null); 

    TextView tv=(TextView)popup.findViewById(R.id.title); 

    tv.setText(marker.getTitle()); 
    tv=(TextView)popup.findViewById(R.id.snippet); 
    tv.setText(marker.getSnippet()); 

    return(popup); 
    } 
} 

3 단계 : 여기 PopupAdapter 클래스 당신의 활동에의 GoogleMap으로에 어댑터 설정 :

mMap.setInfoWindowAdapter(new PopupAdapter(getLayoutInflater())); 

을 그리고 당신이 설정됩니다!

+0

Error inflating Class, @ this line 팝업보기 = inflater.inflate (R.layout.popup, null); 02-06 14 : 40 : 54.950 : E/AndroidRuntime (24275) : 원인 : android.content.res.리소스 $ NotFoundException : 리소스는 드로어 블 (색상 또는 경로)이 아닙니다 : TypedValue {t = 0x1/d = 0x7f020078 a = -1 r = 0x7f020078} –

+0

고마워, 도움이되는 질문과 대답. –

3

이 명령을 사용해야합니다. .title("\u200e"+"عربی").

+0

완벽! 짧고 달다!!! – offset