Answer the question
In order to leave comments, you need to log in
Why doesn't multitouch work?
On the screen are ImageView and SeekBar elements. you need to move both elements at the same time: change the value of the seekbar and move the imageView.
case MotionEvent.ACTION_MOVE does not work on this code:
(if the code is moved to case MotionEvent.ACTION_DOWN, then only one touch works.)
OnTouchListener onTch = new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{ // индекс касания
int pointerIndex = event.getActionIndex();
ClipData clipData = ClipData.newPlainText("", "");
View.DragShadowBuilder dsb = new View.DragShadowBuilder(imV);
// событие
int actionMask = event.getActionMasked();
switch (actionMask) {
case MotionEvent.ACTION_DOWN: // первое касание
//inTouch = true;
break;
case MotionEvent.ACTION_POINTER_DOWN: // последующие касания
break;
case MotionEvent.ACTION_UP: // прерывание последнего касания
//inTouch = false;
break;
case MotionEvent.ACTION_POINTER_UP: // прерывания касаний
// upPI = pointerIndex;
break;
case MotionEvent.ACTION_MOVE: // движение
Log.d(TAG, "intouch1="+inTouch);
if(v.getId()==R.id.imageView);
{
Log.d(TAG, "v.getId="+v.getId());
Log.d(TAG, "R.id.imageView="+R.id.imageView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Log.d(LOG_TAG, "startDragAndDrop1");
v.startDragAndDrop(clipData, dsb, v, 0);
Log.d(LOG_TAG, "startDragAndDrop2");
} else {
Log.d(LOG_TAG, "startDragAndDrop3");
v.startDrag(clipData, dsb, v, 0);
Log.d(LOG_TAG, "startDragAndDrop4");
}
v.setVisibility(View.INVISIBLE);
Log.d(LOG_TAG, "1234");
}
break;
}
return false;
}
};
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
String val_seekBar=String.valueOf(100+seekBar.getProgress());
mTextView.setText(val_seekBar);
}
@Override
public boolean onTouch(View v, MotionEvent event) {
// событие
int actionMask = event.getActionMasked();
// индекс касания
int pointerIndex = event.getActionIndex();
// число касаний
int pointerCount = event.getPointerCount();
switch (actionMask) {
case MotionEvent.ACTION_DOWN: // первое касание
inTouch = true;
case MotionEvent.ACTION_POINTER_DOWN: // последующие касания
downPI = pointerIndex;
break;
case MotionEvent.ACTION_UP: // прерывание последнего касания
inTouch = false;
tx1.setText("0");
tx2.setText("0");
tx3.setText("0");
case MotionEvent.ACTION_POINTER_UP: // прерывания касаний
upPI = pointerIndex;
break;
case MotionEvent.ACTION_MOVE: // движение
switch (v.getId()) {
case R.id.button:
tx1.setText("Нажата кнопка Button1");
break;
case R.id.button2:
tx2.setText("Нажата кнопка Button2");
break;
}
break;
}
return true;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question