capture keyevent in mapview.

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

capture keyevent in mapview.

Postby phannguyen » Thu Oct 09, 2008 4:04 am

hi all,
how can i capture KeyEvent.KEYCODE_DPAD_UP in mapview?
i do like this but it not work:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class TrackingMapActivity extends MapActivity
  2.  
  3. {
  4.  
  5.    @Override
  6.  
  7.     public void onCreate(Bundle icicle) {
  8.  
  9.         super.onCreate(icicle);
  10.  
  11.        
  12.  
  13.         setContentView(R.layout.map);
  14.  
  15.        // Get the map view from resource file
  16.  
  17.        TrackingMapViewer mMapView = (TrackingMapViewer)findViewById(R.id.mv);
  18.  
  19.      
  20.  
  21.         mMapView.setOnKeyListener(new View.OnKeyListener()
  22.  
  23.         {
  24.  
  25.  
  26.  
  27.                         public boolean onKey(View v, int keyCode, KeyEvent event) {
  28.  
  29.                                 // TODO Auto-generated method stub
  30.  
  31.                               if ( keyCode == KeyEvent.KEYCODE_DPAD_UP)                
  32.  
  33.                                 {
  34.  
  35.                                         //move map up.
  36.  
  37.                                 }
  38.  
  39.                                
  40.  
  41.                                 return false;
  42.  
  43.                         }
  44.  
  45.                     });
  46.  
  47.          }
  48.  
  49. }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


thanks for help.
PhanNguyen
phannguyen
Experienced Developer
Experienced Developer
 
Posts: 56
Joined: Thu Jul 17, 2008 7:37 am

Top

Postby plusminus » Thu Oct 09, 2008 6:19 am

Hi phannguyen,

did you try overriding onKeyDown of the MapActivity :?:

Thats at least how I do it.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby phannguyen » Thu Oct 09, 2008 9:24 am

hi plusminus,
i missing focus on mapview,so i can't capture event of dpad keys.
Now i have a query, i can zoomin map by double click on map?

thanks a lot.
PhanNguyen
phannguyen
Experienced Developer
Experienced Developer
 
Posts: 56
Joined: Thu Jul 17, 2008 7:37 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests