2011-12-17 3 views
0

dispatchTap() 메소드를 클릭하면 새 레이아웃을 표시하고 싶습니다. 어떻게 .. 현재 위치에 을 클릭에 새로운 레이아웃을 부풀려 수 있습니다이 내 코드안드로이드의지도에서 현재 위치를 클릭하면 어떻게 새 레이아웃을 열 수 있습니까?

public class CurrentLocationOverlay extends MyLocationOverlay { 

    private Context mContext; 
    private MapView mMapView; 
    private Location mCurrentLocation; 
    private MapController myMapController; 
    double latitude, longitude; 

    public CurrentLocationOverlay(Context context, MapView mapView) { 
     super(context, mapView); 
     mContext = context; 
     mMapView = mapView; 
    } 

    @Override 
    protected boolean dispatchTap() { 
     // TODO handle a tap on "my location point", eg. display an option to 
     // send SMS, make a call, add a picture to current location point. 

      Toast.makeText(mContext, "Suppressing data readout", Toast.LENGTH_SHORT).show(); 

     return true; 
    } 
    /*LayoutInflater layoutInflater = (LayoutInflater) 
    mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
LayoutParams lp = new MapView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, p, LayoutParams.WRAP_CONTENT); 
LinearLayout view = (LinearLayout)inflater.inflate(R.layout.map_overlay, null); 
*/ 

}![enter image description here][1] 

답변

0

사용 ViewFlipper입니다.

<?xml version="1.0" encoding="utf-8"?> 
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/vf" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <include android:id="@+id/main1" layout="@layout/main1" /> 
    <include android:id="@+id/main2" layout="@layout/main2" /> 

</ViewFlipper> 

는 main1.xml는지도보기를 포함하고지도에 현재 위치를 클릭하면 main2.xml는 표시 할 레이아웃을 포함한다고 가정 해 봅시다.

ViewFlipper vf = (ViewFlipper)findViewById(R.id.vf); 

그럼 내가 당신을 도울 수있다 생각이 코드

@Override 
protected boolean dispatchTap() { 
    // TODO handle a tap on "my location point", eg. display an option to 
    // send SMS, make a call, add a picture to current location point. 
    vf.setDisplayChild(1); // to display main2.xml 
     Toast.makeText(mContext, "Suppressing data readout", Toast.LENGTH_SHORT).show(); 

    return true; 
} 

를 사용합니다.

+0

을 도울 수 없다 위치는 작은 레이아웃을 보여줍니다 .. 안드로이드 맵 applcation을 확인하십시오. 현재 위치를 클릭하면 작은 레이아웃이 표시됩니다. –

+0

지도를 클릭 할 때 현재 화면을 변경하는 새로운 레이아웃을 표시해야한다고 생각했습니다. 이제 나는 무엇을 요구하고 있는지 이해했다. 지도 오버레이를 사용하면 **지도 ** 응용 프로그램과 동일한 효과를 얻을 수 있다고 생각합니다. 한 번 해봐. 나는 또한 검사 할 것이다. 의견을 주셔서 감사합니다. 안녕 –

+0

도와 주셔서 고마워 ...하지만 내가 지금 이해하고 싶습니다 ... 나는 그것이 MyLocationOverlay에서만 가능하다고 생각합니다. 현재 위치를 처리하는 Click 이벤트 .. 주석으로 언급. –