Press multiple buttons with a single action.

Put your problem here if it does not fit any of the other categories.

Press multiple buttons with a single action.

Postby MrSoda » Wed Jan 06, 2010 1:10 pm

Hi, I stumbled upon this forum after some heavy Google-ing and am posting because of a roadblock in my first Android application. Basically I'm trying to sweep across a series of buttons, and have all of the ones pressed perform an action without the need to take your finger off the screen (like a piano). So far, most of what I have is a bunch of on touch listeners that play a sound on a button press and then stop playing and reset the sound to 0ms after the button is released (which works for the most part), like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.                 gAS2.setOnTouchListener(new View.OnTouchListener()
  3.  
  4.                 {
  5.  
  6.                                 @Override
  7.  
  8.                                 public boolean onTouch(View v, MotionEvent event)
  9.  
  10.                                 {
  11.  
  12.                                         if (event.getAction() == MotionEvent.ACTION_DOWN)
  13.  
  14.                                         {
  15.  
  16.                                                 gAS2Sound.start();
  17.  
  18.                                         }                      
  19.  
  20.                                         else if (event.getAction() == MotionEvent.ACTION_UP)
  21.  
  22.                                         {
  23.  
  24.                                                 gAS2Sound.pause();
  25.  
  26.                                                 gAS2Sound.seekTo(0);                                           
  27.  
  28.                                         }
  29.  
  30.                                         return true;
  31.  
  32.                                 }              
  33.  
  34.                 });
  35.  
  36.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Any idea how to make the button sweeping work?
MrSoda
Freshman
Freshman
 
Posts: 2
Joined: Wed Jan 06, 2010 12:51 pm

Top

Postby MrSoda » Sat Jan 09, 2010 3:50 pm

This person seems to have the same problem:

http://groups.google.com/group/android- ... 200241405d

Any ideas?
MrSoda
Freshman
Freshman
 
Posts: 2
Joined: Wed Jan 06, 2010 12:51 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 16 guests