2012-06-04 2 views
0

런타임에지도를 추가하고 (지도에서 보이는 것처럼) 버튼을 사용하여지도의 유형 (일반/위성/교통)을 제어하고 싶습니다. 내가 여기에, 버튼 "아래"갈 수있는지도를 얻을 수 디버그/릴리스를 기반으로 API 키를 선택합니다 이후안드로이드는지도 위에 투명 버튼이 프로그래밍 방식으로 추가합니다.

나는 그러나

<RelativeLayout ...> 
<map> 
<button .../> 
<button .../> 
</RelativeLayout> 

처럼 XML로 무엇을한다 할 수있는 전 난 단지 전체 화면에서지도를 볼 수있다

this.mapView = new MyMapView(this, map_key); 
     this.mapView.setClickable(true); 

     RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); 
     //p.addRule(RelativeLayout.BELOW, R.id.tipo_mappa); 
     p.addRule(RelativeLayout.CENTER_IN_PARENT); 


     this.mapView.setLayoutParams(p); 



     layout.addView(this.mapView, 0); 

결과를 시도, 버튼은 아래 어쩌면/숨겨져 있습니다. 그것은 작동하지만지도를 추가 한 후 다시 버튼에 초점을 요청하려고합니다 경우

내 layout.xml

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/linearLayoutMappa" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 




    <!-- 

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

    --> 

    <RadioGroup 
     android:id="@+id/tipo_mappa" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:orientation="horizontal" > 

     <RadioButton 
      android:id="@+id/normal" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:checked="true" 
      android:text="@string/mappa_normale" /> 

     <RadioButton 
      android:id="@+id/sat" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="8dp" 
      android:text="@string/mappa_satelite" /> 
    </RadioGroup> 

    <CheckBox 
     android:id="@+id/traffic" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_toRightOf="@+id/tipo_mappa" 
     android:onClick="myClickHandler" 
     android:text="@string/mappe_traffic" /> 

</RelativeLayout> 
+0

Hav 당신은'setContentView (this.mapView)'를 사용하려고 시도한 후에 XML을 부풀리고'addContentView'를 사용합니까? –

+0

나는 시도했지만 충돌을 계속하고, 뭔가 잘못하고 있어야합니다. – max4ever

+0

ReqeuestFocus가 문제를 해결합니까? 그렇지 않으면 StackTrace를 추가하십시오. –

답변

관련 문제