I tried to detect two touches on my two shaped buttons, which are single. Relative layout. The problem is that it shows action_down values ββfor both buttons, but does not have an action pointer value.
My code is as follows:
private int getIndex(MotionEvent event) { int idx = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; return idx; } @Override public boolean onTouch(View paramView, MotionEvent paramMotionEvent) { // TODO Auto-generated method stub // Boolean state=false; // int pointerCount = paramMotionEvent.getPointerCount(); boolean val = false; int pointerIndex = paramMotionEvent.getAction() & MotionEvent.ACTION_MASK; switch(pointerIndex) { case MotionEvent.ACTION_DOWN :{ Log.i("fil", "action dowm"); break; } case MotionEvent.ACTION_POINTER_DOWN :{ int id = paramMotionEvent.getPointerId(getIndex(paramMotionEvent)); Log.d("fil", "Other point down ["+id+"]"); Log.i("fil", "action pointer down"); break; } case MotionEvent.ACTION_POINTER_UP :{ int id = paramMotionEvent.getPointerId(getIndex(paramMotionEvent)); Log.d("fil", "Other point down ["+id+"]"); Log.i("fil", "action pointer up"); break; } case MotionEvent.ACTION_UP :{ Log.i("fil", "action up"); break; } } 'my xml' <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:gravity="center"> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" > </RelativeLayout> <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/ic_launcher" /> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="100dp" android:background="@drawable/ic_launcher" />
source share