Hi,
May be this is a late answer !
Never mind, as I went through this problem, I post here the solution I
found.
As the ACTION_DOWN is called only once while the user is pressing the
screen, the idea is to post a delayed event to detected the long press
What I've done :
At the beginning of the class extending View :
final Handler handler = new Handler();
Runnable mLongPressed = new Runnable() {
public void run() { if (downMode) mAct.openContextMenu
(ObjectView.this); } // To open the context menu
};
In the callback :
public boolean onTouchEvent(MotionEvent e) {
switch(e.getAction()) {
case MotionEvent.ACTION_DOWN:
handler.postDelayed(mLongPressed, 1500); //LongPressed
after
1,5s
downMode = true;
In the other modes such as ACTION_MOVE and ACTION_UP, I reset the
downMode boolean to false. So when the delay expires, if the user is
still pressing the screen, downMode is true and I show the context
menu
Hope this helps a bit !
BR
On 14 août, 00:11, mscwd01 <[email protected]> wrote:
> That sounds like a hacky way of doing things, isn't there a "proper"
> way of implementing this?
>
> On Aug 13, 4:49 pm, Pugnap00 <[email protected]> wrote:
>
> > What about setting up a time for when the screen is being pressed. You
> > could use a while loop, and after a certain amount of ticks you execue
> > your code.
>
> > On Aug 13, 7:47 am, mscwd01 <[email protected]> wrote:
>
> > > Hey,
>
> > > I want to be able to detect where a user has long pressed on my Map
> > > Overlay.
>
> > > The idea being to get the GeoPoint of the location the user pressed.
>
> > > I can detect where a user taps, but cannot find how to detect a long
> > > press.
>
> > > Any ideas?
>
> > > Thanks
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---