Try to use the   dispatchTouchEvent() method (http://
developer.android.com/reference/android/app/
Activity.html#dispatchTouchEvent(android.view.MotionEvent) which is
called to process touch screen events.



Your method would look like


        static boolean touchingScreen = false;
        ....

        @Override
        public boolean dispatchTouchEvent (MotionEvent ev)
        {
           super.dispatchTouchEvent(ev);
           switch (ev.getAction()) {
                case MotionEvent.ACTION_DOWN: {

                  touchingScreen = true;

                  //call your method  (use an intent to start your
repeating event)
                break;
                case MotionEvent.ACTION_UP:

                  touchingScreen = false; (use an intent to stop your
repeating event)
                break;
           }
        }

Within the ACTION.DOWN (touching the screen) you could call another
method which runs in a different thread.
The thread terminates when touchingScreen = false which means that you
received the ACTION.UP event. Make sure that your loop does not block
the UI.

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.



On Jul 13, 5:05 am, Daliz <[email protected]> wrote:
> Hello,
>
> I'm having a conceptual problem with a simple application.
>
> I have an empty FrameLayout and I want for a certain event to being
> continuosly repeated until the finger leaves the display.
>
> If I apply:
>
> ### code ###
>
> frameLayout.setOnTouchListener(new View.OnTouchListener() {
>
> public boolean onTouch(View v, MotionEvent event) {
>
> myEvent();
>
> return false;
>  }
>
> });
>
> ### /code ###
>
> I get a single instance of my event. But I want my event to be
> repeated until the finger stops touching.
>
> How can I do?
>
> Thank you Smile
--~--~---------~--~----~------------~-------~--~----~
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