Hi,

I'm facing an very simple (and stupid) issue and I hope someone will
be able to provide me an explanation...

I'm trying to develop an Activity with 2 buttons (let's call them btnA
and btnB), they are in my xml layout. My goal is to be able to handle
click on both button (easy), even on the same time with multi-touch.

First, I retrieve them on the onCreate method and I set them the
OnTouchListener to this (my Activity implements OnTouchListener):

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

                this.btnA = (ImageButton) this.findViewById(R.id.btnA);
                this.btnB = (ImageButton) this.findViewById(R.id.btnB);

                this.btnA.setOnTouchListener(this);
                this.btnB.setOnTouchListener(this);
        }

I did override the onTouch method that way :
@Override
        public boolean onTouch(View v, MotionEvent event) {
                int action = event.getAction() & MotionEvent.ACTION_MASK;
                if(v.equals((View)this.btnA)){
                        if(action == MotionEvent.ACTION_DOWN){
                                updateAState(true);
                        }else if(action == MotionEvent.ACTION_UP){
                                updateAState(false);
                        }
                }else if(v.equals((View)this.btnB)){
                        if(action == MotionEvent.ACTION_DOWN){
                                updateBState(true);
                        }else if(action == MotionEvent.ACTION_UP){
                                updateBState(false);
                        }
                }
                return true;
        }

With this implementation, I can capture the DOWN and UP event on both
buttons, but not with multi-touch (ex: btnA DOWN, btnB DOWN, btnB UP,
btnB DOWN, btnB UP, btnA UP).

Who can tell me how I can fix my onTouch method to support such
feature ?

Thanks a lot.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to