drag/slide finger to perform onclick buttons- multitouch

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

drag/slide finger to perform onclick buttons- multitouch

Postby Nia » Thu Sep 15, 2011 5:27 pm

i have a game, consisting of 7 buttons , arranged such that 1 button is in the center and rest 6 around it.
click on the buttons results in change in textview. using click can really be cumbersome for the user, therefore i would
like to add functionality of dragging finger over buttons to perform onclick ..something similar to boggle type of games like ->https://market.android.com/details?id=com.ant.wordfind.client&feature=search_result

i have tried to implement the same ,problem is when i drag of finger only one button gets registered , even if i press other buttons by dragging cursor -> other button touch are just ignored.given the
following code.

Code: Select all
public boolean onTouch(View v, MotionEvent arg1) {
                if(arg1.getAction() ==MotionEvent.ACTION_MOVE)
        {
                Button b;
                switch (v.getId())
        {
        case R.id.b1:
        case R.id.b2:
        case R.id.b3:
        case R.id.b4:
        case R.id.b5:
        case R.id.b6:
        case R.id.b7:
              b = (Button)findViewById(v.getId());
              b.performClick();
                break;
        }
     return true;
        }


am i missing somethng ? wht i want is whn buttons are touched ..they perform onclick functionality.once one button click is registered rest touches are ignored :(
any help would be appreciated :)

here is a similar problem which is unresolved on this forum- post98618.html#p98618
Nia
Freshman
Freshman
 
Posts: 8
Joined: Fri Jun 18, 2010 6:29 pm

Top

Re: drag/slide finger to perform onclick buttons- multitouch

Postby redbulletnl » Fri Sep 16, 2011 10:14 am

Code: Select all
private OnClickListener mAddListener = new OnClickListener()
    {
       public void onClick(View v)
       {
          switch(v.getId())
          {
        case R.id.b1:
        break;
        case R.id.b2:
        break;
        case R.id.b3:
        break;
        case R.id.b4:
        break;
        case R.id.b5:
        break;
        case R.id.b6:
        break;
        case R.id.b7:
        break;


this is how i use my touch / click events ;)
redbulletnl
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Sep 14, 2011 7:44 am

Re: drag/slide finger to perform onclick buttons- multitouch

Postby Nia » Fri Sep 16, 2011 1:01 pm

u missed the whole point of my question :|
i knw what onclick listener is..and how it works ...
onclick allows just one button to be clicked at a time ..wht i want is tht user shud be able to perform click by dragiing finger over buttons ..like in all boggle type word games
Nia
Freshman
Freshman
 
Posts: 8
Joined: Fri Jun 18, 2010 6:29 pm

Re: drag/slide finger to perform onclick buttons- multitouch

Postby jonbonazza » Fri Sep 16, 2011 7:57 pm

You could use a View.OnTouchListener.

http://developer.android.com/reference/ ... tener.html

The MotionEvent paramenter of the overridden onTouch method allows you to check for various motion events such as MotionEvent.ACTION_UP, MotionEvent.ACTION_DOWN, and MotionEvent.ACTION_MOVE, along with the View associated with each action.
jonbonazza
Master Developer
Master Developer
 
Posts: 665
Joined: Thu Jul 15, 2010 2:58 pm
Location: WV USA

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests