Saturday 15 May 2010

java - Android OnLongClickListener not firing on MapView -


I have just registered an onlineclicklist on my My Maps view on an Android app, which I am currently writing.

  Applies to the public-class FriendMapActivity MapActivity OnLongClickListener {Private Static last int CENTER_MAP = menu.update; See a private map map map; Map Controller of Private Map Controller; // ... private boolean doCenterMap = true; /** Called when the activity is first created. * / @ Override Crate on Public Zero (Bundle Saved Instantstate) {Super. Contents (Saved Instantstate); SetContentView (R.layout.friendmapview); This.mapView = (MapView) findViewById (R.id.map_view); This.mapController = mapView.getController (); MapView.setBuiltInZoomControls (true); MapView.displayZoomControls (true); MapView.setLongClickable (true); MapView.setOnLongClickListener (New OnlineClicklist) {Public Boolean On Longclick (see V) {// Never Returns Url; False Return;}}); // ...} Override public boolean on @KeyDown (intccode, key event event) {switch (keycode) {case of event. KEYCODE_3: mapController.zoomIn (); break; Kyle Kyle. KEYCODE_1: mapController.zoomOut (); break; } Return super.Condondon (keycode, event); } @ Override Public Boolean Dispatch Touch Event (Motion Avene Eve) {int action type = ev.getAction (); Switch (action type) {case MotionEvent.ACTION_MOVE: doCenterMap = false; break; } Return super. Descapture Event (Eve); } ...}  

May the overlay which is adding the cause of the problem to me ?? Any suggestions?

I just ran into this problem I tried the solution given above, but it A lot of <100% do not work, we want the press action to fire for a long time, even if the user is still holding a finger.

Similarly, I have implemented a solution using a handler and delayed work - as a side note, I have used a similar type of implementation, but in reverse, touch / touch / Zoom control to show zoom control.

Private handler mHandler = new handler (); Private Finals Runable mTask = New Runnabal () {@ Override Public Wired Run ()} // {Your Code Here}}; @ Override Public Boolean On Touch Event (Motion Avenger Eva) {if (ev.getAction () == MotionEvent.ACTION_DOWN) {// Start the start time, start the timer mEventStartTime = ev.getEventTime (); MHandler.post delimited (mTask, LONG_PRESS_TIME); } Else if (ev.getAction () == MotionEvent.ACTION_UP) {// Record the end time, do not show that long enough is not enough mEventEndTime = ev.getEventTime (); If (mEventEndTime - mEventStartTime & lt; LONG_PRESS_TIME) {mHandler.removeCallbacks (mTask); }} And {// proceeding, panning, etc. Do you want to // that you count it as a long press - mEventStartTime = ev.getEventTime (); MHandler.removeCallbacks (mTask); MHandler.post delimited (mTask, LONG_PRESS_TIME); } Return super. Tontivent (Eve); }

No comments:

Post a Comment