Capturing ACTION_MOVE events over multiple OnTouchListener

by RF » Mon, 27 Apr 2009 16:26:04 GMT


Sponsored Links
 Hello Folks!

I am developing an application where at one point the user is
presented with six identical images each placed side by side.  The
user can then select any of the six images, one after another, by
swiping his finger over the desired images he wishes to select.

I have used a table layout to place the images side by side within
image views for each of the images. Then I set OnTouchListener for
each ImageView.  The OnTouchListener listens for an ACTION_MOVE
MotionEvent whereby a textbox is set to display the view on which the
motion event was captured on.

My problem lies in coding the part where the user makes the selection
by swiping his finger over the images. The OnTouchListener captures
the motion event on the first image the user swipes his finger on but
it doesn ransferthe listener to the other images while the user
keeps swiping his finger over the other images. This results in the
motion being captured on just one image all the time even while the
user continues swiping his finger over other images.

How should I code this so that the program detects the user swiping
his finger over multiple images one by one?

This has been bugging me for two days now. Any help will be
appreciated!

Here's my code:

package com.blah.myRun

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class sticks extends Activity implements View.OnTouchListener {
       /** Called when the activity is first created. */
       ImageView img1, img2, img3, img4, img5, img6
       TextView myText;

       @Override
       public void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
               setContentView(R.layout.main);

               /** Create instances to the individual images */
               img1 = (ImageView) findViewById(R.id.button1);
               img2 = (ImageView) findViewById(R.id.button2);
               img3 = (ImageView) findViewById(R.id.button3);
               img4 = (ImageView) findViewById(R.id.button4);
               img5 = (ImageView) findViewById(R.id.button5);
               img6 = (ImageView) findViewById(R.id.button6);
               myText = (TextView)findViewById(R.id.myText);

               /** Bind instances to listeners */
               img1.setOnTouchListener(this);
               img2.setOnTouchListener(this);
               img3.setOnTouchListener(this);
               img4.setOnTouchListener(this);
               img5.setOnTouchListener(this);
               img6.setOnTouchListener(this);


       }


       @Override
       public boolean onTouch(View v, MotionEvent event) {



               /** On move, figure out which button the movement is
on*/


               switch (event.getAction()) {
               case MotionEvent.ACTION_MOVE: {
                       myText.setText(v.toString());

               break;
               }




               return true;


       }


}

--~--~---------~--~----~------------~-------~--~----~



Capturing ACTION_MOVE events over multiple OnTouchListener

by RF » Mon, 27 Apr 2009 16:28:31 GMT


 Hello Folks!

I am developing an application where at one point the user is
presented with six identical images each placed side by side.  The
user can then select any of the six images, one after another, by
swiping his finger over the desired images he wishes to select.

I have used a table layout to place the images side by side within
image views for each of the images. Then I set OnTouchListener for
each ImageView.  The OnTouchListener listens for an ACTION_MOVE
MotionEvent whereby a textbox is set to display the view on which the
motion event was captured on.

My problem lies in coding the part where the user makes the selection
by swiping his finger over the images. The OnTouchListener captures
the motion event on the first image the user swipes his finger on but
it doesn ransferthe listener to the other images while the user
keeps swiping his finger over the other images. This results in the
motion being captured on just one image all the time even while the
user continues swiping his finger over other images.

How should I code this so that the program detects the user swiping
his finger over multiple images one by one?

This has been bugging me for two days now. Any help will be
appreciated!

Here's my code:

package com.blah.myRun

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class sticks extends Activity implements View.OnTouchListener {
       /** Called when the activity is first created. */
       ImageView img1, img2, img3, img4, img5, img6
       TextView myText;

       @Override
       public void onCreate(Bundle savedInstanceState) {
               super.onCreate(savedInstanceState);
               setContentView(R.layout.main);

               /** Create instances to the individual images */
               img1 = (ImageView) findViewById(R.id.button1);
               img2 = (ImageView) findViewById(R.id.button2);
               img3 = (ImageView) findViewById(R.id.button3);
               img4 = (ImageView) findViewById(R.id.button4);
               img5 = (ImageView) findViewById(R.id.button5);
               img6 = (ImageView) findViewById(R.id.button6);
               myText = (TextView)findViewById(R.id.myText);

               /** Bind instances to listeners */
               img1.setOnTouchListener(this);
               img2.setOnTouchListener(this);
               img3.setOnTouchListener(this);
               img4.setOnTouchListener(this);
               img5.setOnTouchListener(this);
               img6.setOnTouchListener(this);


       }


       @Override
       public boolean onTouch(View v, MotionEvent event) {



               /** On move, figure out which button the movement is
on*/


               switch (event.getAction()) {
               case MotionEvent.ACTION_MOVE: {
                       myText.setText(v.toString());

               break;
               }




               return true;


       }


}

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Capturing ACTION_MOVE events over multiple OnTouchListener

by RF » Mon, 27 Apr 2009 16:33:44 GMT


 Hello Folks!

I am developing an application where at one point the user is
presented with six identical images each placed side by side.  The
user can then select any of the six images, one after another, by
swiping his finger over the desired images he wishes to select.

I have used a table layout to place the images side by side within
image views for each of the images. Then I set OnTouchListener for
each ImageView.  The OnTouchListener listens for an ACTION_MOVE
MotionEvent whereby a textbox is set to display the view on which the
motion event was captured on.

My problem lies in coding the part where the user makes the selection
by swiping his finger over the images. The OnTouchListener captures
the motion event on the first image the user swipes his finger on but
it doesn ransferthe listener to the other images while the user
keeps swiping his finger over the other images. This results in the
motion being captured on just one image all the time even while the
user continues swiping his finger over other images.

How should I code this so that the program detects the user swiping
his finger over multiple images one by one?

This has been bugging me for two days now. Any help will be
appreciated!

Here's my code:

package com.blah.myRun

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class sticks extends Activity implements View.OnTouchListener {
        /** Called when the activity is first created. */
        ImageView img1, img2, img3, img4, img5, img6
        TextView myText;

        @Override
        public void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);

                /** Create instances to the individual images */
                img1 = (ImageView) findViewById(R.id.button1);
                img2 = (ImageView) findViewById(R.id.button2);
                img3 = (ImageView) findViewById(R.id.button3);
                img4 = (ImageView) findViewById(R.id.button4);
                img5 = (ImageView) findViewById(R.id.button5);
                img6 = (ImageView) findViewById(R.id.button6);
                myText = (TextView)findViewById(R.id.myText);

                /** Bind instances to listeners */
                img1.setOnTouchListener(this);
                img2.setOnTouchListener(this);
                img3.setOnTouchListener(this);
                img4.setOnTouchListener(this);
                img5.setOnTouchListener(this);
                img6.setOnTouchListener(this);


        }


        @Override
        public boolean onTouch(View v, MotionEvent event) {



                /** On move, figure out which button the movement is on*/


                switch (event.getAction()) {
                case MotionEvent.ACTION_MOVE: {
                        myText.setText(v.toString());

                break;
                }




                return true;


        }


}

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. playing RTP/TCP/AVP video stream (RTSP over HTTP tunnel)

Hello!

We are trying to play a video stream on the Android platform, with no
success.
Using the VideoView, we are able to play youtube mobile videos (e.g.
this url works just fine:
rtsp://v3.cache7.c.youtube.com/CjYLENy73wIaLQnMYzt2FtQmqxMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYI6vr52RlLW1Sww=/0/0/0/video.3gp
)

However, we need to play a given stream from an RTSP url, over which
we have no control.
The RTSP server delivers RTP/TCP/AVP packets interleaved over RTSP.
RTSP itself is supported via HTTP tunnelling over port 80.
The video format is MPEG4-Part2 (H.263).
Moreover, the rtsp url can be used one time only; built with a key-
string every time. On a desktop system, quicktime could play the
stream, VLC could not.

Is it possible to play back such a stream on an Android device
somehow?

I read googling around that the builtin (openCore?) RTP stack only
supports RTP over UDP, not TCP. Is this (still) true?
Can I somehow bypass this problem?

Thanks!
Turi Andrs

-- 

2. Can't download the Android SDK

"Failed to fetch URL 
https://dl-ssl.google.com/android/repository/repository.xml,
reason: HTTPS SSL error. You might want to force download through HTTP
in the settings." ..the error i get each time i run the setup.exe for
android
??
thanks in advance
Dick

-- 

3. [ASK] Newbie coders in android

4. Need help with twitter integration

5. G-Sensor

6. GL_LINES clipping problem in emulator?

7. MMS not going through to iphone