Detecting long touch press (ACTION_DOWN only)??

by eminemence » Thu, 02 Sep 2010 01:55:07 GMT


Sponsored Links
 Hi,
I want to figure out how to detect that the user has been doing a long
touch press on the screen?
Most of the solutions that I see assume that the DOWN + UP sequence of
events.
Thanks in advance.

--



Detecting long touch press (ACTION_DOWN only)??

by fr4gus » Thu, 02 Sep 2010 02:22:06 GMT


 If you don't have a requirement about how long should be the time to
trigger a long press, you could use

android.view.GestureDetector;

android.view.GestureDetector.SimpleOnGestureListener;

If you need to detect a long in a specific View object, what I do is
to register a OnTouchListener in my View object, that will redirect
the MotioEvent to the GestureDetector. At this point I'm able to
record what View was touched, and keep it in a variable of my current
Activity. Then in the gesture listener I took this variable and use
it. But if someone else knows a better approach I would like to hear
it :).

Best,

fr4gus




--


Sponsored Links


Other Threads

1. Status Bar appears again

Hi,

I am developing a Home Screen and I have set the following attributes
in AndroidManifest.xml
android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"

as well as in onCreate() function as
// programatically setting the "No Status Bar" and "Fullscreen" for
this application
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);


This works fine as long as my application starts running in the
foreground for the first time but once I activate any other
application by touching corresponding application icon and it (my
application) goes to background, the status bar appears when it
returns to foreground stays there.

Why it would have such characteristics even though I've explicitly
set above attributes.

Thanks in advance

Regards,
argongold

-- 

2. Wtw Modaco Nexus S

Ada Yang punya link ROM Modaco buat NS
Mau coba.....

Makasih

Regards : Cakra
Cyanogen Nexus S

-- 
===============

3. From the Bottom of My Heart

4. Paging user Nexus S

5. Need Help in Android developement

6. Custom Drawable in OverlayItem in wrong location

7. How to open email in app with address