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]
4

2 に答える 2

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 には MapView が含まれ、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;
}

私はそれがあなたを助けるかもしれないと思う.

于 2011-12-17T10:19:46.320 に答える