hi Guillaume
    I got it. Thanks for your valuable response. I also implemented it
in overlay.

On 12月27日, 上午12时06分, "Guillaume Perrot" <[email protected]>
wrote:
> I realized I was calling myself openContextMenu in my code, for tap events
> on overlays...
> I don't know how to handle long clicks on the map, sorry.
>
> 2008/12/26 [email protected] <[email protected]>
>
>
>
>
>
>
>
> > hi Guillaume
> >    it seems I can't still work it out. log click got no response as
> > before. below is the code and xml files.
> > package android.demo;
> > import com.google.android.maps.MapActivity;
> > import android.os.Bundle;
> > import com.google.android.maps.MapView;
> > import android.view.ContextMenu;
> > import android.view.KeyEvent;
> > import android.view.View;
> > import android.util.*;
> > public class demo extends MapActivity {
> >    /** Called when the activity is first created. */
> >        MapView mapView;
> >    @Override
> >    public void onCreate(Bundle savedInstanceState) {
> >        super.onCreate(savedInstanceState);
> >        setContentView(R.layout.main);
> >        mapView = (MapView) findViewById(R.id.mapview1);
> >        // We also want to show context menu for longpressed items in
> > the gallery
> >      //init the map view
> >         mapView.setLongClickable(true);
> >         registerForContextMenu(mapView);
>
> >    }
>
> >    public void onCreateContextMenu(ContextMenu menu, View v,
> > ContextMenu.ContextMenuInfo menuInfo) {
> >                  menu.setHeaderTitle("Menu");
> >              menu.add(0, 1, 0, "Add");
> >              menu.add(0, 2, 0, "Delete");
> >              menu.add(0, 3, 0, "Edit");
> >           }
> >    public boolean onKeyDown(int keyCode, KeyEvent event) {
> >        if (keyCode == KeyEvent.KEYCODE_Z) {
> >                mapView.getController().zoomIn();
> >                return true;
> >        } else if (keyCode == KeyEvent.KEYCODE_X) {
> >                mapView.getController().zoomOut();
> >                return true;
> >        }
>
> >        return super.onKeyDown(keyCode, event);
> > }
>
> >    @Override
> >    protected boolean isRouteDisplayed() {
> >        // TODO Auto-generated method stub
> >        return false;
> >    }
> > }
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> > android"
> >    android:orientation="vertical"
> >    android:layout_width="fill_parent"
> >    android:layout_height="fill_parent"
>
> >    <com.google.android.maps.MapView
> >     android:id="@+id/mapview1"
> >    android:layout_width="fill_parent"
> >    android:layout_height="fill_parent"
> >    android:enabled="true"
> >    android:longClickable="true"
> >    android:clickable="true"
> >    android:apiKey="0xliHXBcaVPd0uSCbaQpTRJRFCgsjKu7z0Gsjsw" />
>
> > </LinearLayout>
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <manifest xmlns:android="http://schemas.android.com/apk/res/android";
> >      package="android.demo"
> >      android:versionCode="1"
> >      android:versionName="1.0.0">
> >      <uses-permission
> > android:name="android.permission.ACCESS_FINE_LOCATION"></uses-
> > permission>
>
> >      <uses-permission
> > android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-
> > permission>
> >      <uses-permission android:name="android.permission.INTERNET"></
> > uses-permission>
>
> >    <application android:icon="@drawable/icon" android:label="@string/
> > app_name">
> >              <uses-library android:name="com.google.android.maps" />
>
> >        <activity android:name=".demo"
> >                  android:label="@string/app_name">
> >            <intent-filter>
> >                <action android:name="android.intent.action.MAIN" />
> >                <category
> > android:name="android.intent.category.LAUNCHER" />
> >            </intent-filter>
> >        </activity>
> >    </application>
> > </manifest>
>
> > On 12月26日, 下午9时56分, "Guillaume Perrot" <[email protected]>
> > wrote:
> > > I have the same kind of code, which is working though.
> > > The key difference may be that I call mapView.setLongClickable(true); you
> > > should try it.
>
> > > 2008/12/26 [email protected] <[email protected]>
>
> > > > hi Guillaume
> > > >    Thanks for your response. I tried to override the
> > > > onCreateContextMenu directly in MapActivity. The result is the same as
> > > > the above. Below is the source code.
> > > > package android.demo;
> > > > import com.google.android.maps.MapActivity;
> > > > import android.os.Bundle;
> > > > import com.google.android.maps.MapView;
> > > > import android.view.ContextMenu;
> > > > import android.view.KeyEvent;
> > > > import android.view.View;
> > > > import android.util.*;
> > > > public class demo extends MapActivity {
> > > >    /** Called when the activity is first created. */
> > > >        MapView mapView;
> > > >    @Override
> > > >    public void onCreate(Bundle savedInstanceState) {
> > > >        super.onCreate(savedInstanceState);
> > > >        setContentView(R.layout.main);
> > > >        mapView = (MapView) findViewById(R.id.mapview1);
> > > >        // We also want to show context menu for longpressed items in
> > > > the gallery
> > > >      //init the map view
> > > >        registerForContextMenu(mapView);
>
> > > >    }
> > > >    public void onCreateContextMenu(ContextMenu menu, View v,
> > > > ContextMenu.ContextMenuInfo menuInfo) {
> > > >                  menu.setHeaderTitle("Menu");
> > > >              menu.add(0, 1, 0, "Add");
> > > >              menu.add(0, 2, 0, "Delete");
> > > >              menu.add(0, 3, 0, "Edit");
> > > >           }
> > > >    public boolean onKeyDown(int keyCode, KeyEvent event) {
> > > >        if (keyCode == KeyEvent.KEYCODE_Z) {
> > > >                mapView.getController().zoomIn();
> > > >                return true;
> > > >        } else if (keyCode == KeyEvent.KEYCODE_X) {
> > > >                mapView.getController().zoomOut();
> > > >                return true;
> > > >        }
>
> > > >        return super.onKeyDown(keyCode, event);
> > > > }
>
> > > >    @Override
> > > >    protected boolean isRouteDisplayed() {
> > > >        // TODO Auto-generated method stub
> > > >        return false;
> > > >    }
> > > > }
>
> > > > On 12月26日, 下午8时14分, Guillaume Perrot <[email protected]> wrote:
> > > > > Why don't you override the onCreateContextMenu directly in
> > > > > MapActivity ?
>
> > > > > On Dec 26, 10:15 am, "[email protected]" <[email protected]>
> > > > > wrote:
>
> > > > > > hi all
> > > > > >     I want to create a context menu when LongClick is hitted. As
> > > > > > result mapview is opened successfully; but the LongClick got no
> > > > > > response. Would you like to give me a hand how to solve it? Below
> > is
> > > > > > the complete code. Thank you very much.
>
> > > > > > package android.demo;
> > > > > > import com.google.android.maps.MapActivity;
> > > > > > import android.os.Bundle;
> > > > > > import com.google.android.maps.MapView;
> > > > > > import android.view.ContextMenu;
> > > > > > import android.view.View;
> > > > > > import android.util.*;
> > > > > > public class demo extends MapActivity {
> > > > > >     /** Called when the activity is first created. */
> > > > > >         MapView mapView;
> > > > > >     @Override
> > > > > >     public void onCreate(Bundle savedInstanceState) {
> > > > > >         super.onCreate(savedInstanceState);
> > > > > >         setContentView(R.layout.main);
> > > > > >         mapView = (MapView) findViewById(R.id.mapview1);
> > > > > >         // We also want to show context menu for longpressed items
> > in
> > > > > > the gallery
> > > > > >       //init the map view
>
> > > > > >         mapView.setOnLongClickListener(new
> > View.OnLongClickListener(){
>
> > > > > >         public boolean onLongClick(View v) {
> > > > > >         mapView.showContextMenu();
> > > > > >         return true;
> > > > > >         }
>
> > > > > >         });
>
> > > > > >         mapView.setOnCreateContextMenuListener(new
> > > > > > View.OnCreateContextMenuListener() {
> > > > > >         public void onCreateContextMenu(ContextMenu menu, View v,
> > > > > > ContextMenu.ContextMenuInfo menuInfo) {
> > > > > >                   menu.setHeaderTitle("Menu");
> > > > > >               menu.add(0, 1, 0, "Add");
> > > > > >               menu.add(0, 2, 0, "Delete");
> > > > > >               menu.add(0, 3, 0, "Edit");
> > > > > >            }
> > > > > >         });
>
> > > > > >         registerForContextMenu(mapView);
>
> > > > > >     }
>
> > > > > >     @Override
> > > > > >     protected boolean isRouteDisplayed() {
> > > > > >         // TODO Auto-generated method stub
> > > > > >         return false;
> > > > > >     }
>
> > > > > > }- 隐藏被引用文字 -
>
> > > > > - 显示引用的文字 -
>
> > > --
> > > Guillaume Perrot
> > > Software Engineer at Ubikod
> > > BuddyMob developer- 隐藏被引用文字 -
>
> > > - 显示引用的文字 -
>
> --
> Guillaume Perrot
> Software Engineer at Ubikod
> BuddyMob developer- 隐藏被引用文字 -
>
> - 显示引用的文字 -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to