android.view.MotionEvent.setAction()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(244)

本文整理了Java中android.view.MotionEvent.setAction()方法的一些代码示例,展示了MotionEvent.setAction()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.setAction()方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:setAction

MotionEvent.setAction介绍

暂无

代码示例

代码示例来源:origin: ksoichiro/Android-ObservableScrollView

private MotionEvent obtainMotionEvent(MotionEvent base, int action) {
  MotionEvent ev = MotionEvent.obtainNoHistory(base);
  ev.setAction(action);
  return ev;
}

代码示例来源:origin: seven332/EhViewer

@Override
public boolean onHoverEvent(@NonNull MotionEvent event) {
  AccessibilityManager accessibilityManager =
      (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
  if (accessibilityManager.isTouchExplorationEnabled()) {
    final int action = event.getAction();
    switch (action) {
      case MotionEvent.ACTION_HOVER_ENTER:
        event.setAction(MotionEvent.ACTION_DOWN);
        break;
      case MotionEvent.ACTION_HOVER_MOVE:
        event.setAction(MotionEvent.ACTION_MOVE);
        break;
      case MotionEvent.ACTION_HOVER_EXIT:
        event.setAction(MotionEvent.ACTION_UP);
        break;
    }
    onTouchEvent(event);
    event.setAction(action);
  }
  return super.onHoverEvent(event);
}

代码示例来源:origin: k9mail/k-9

e2.setAction(MotionEvent.ACTION_CANCEL);
} catch (Exception e) {

代码示例来源:origin: alexvasilkov/GestureViews

@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
  super.requestDisallowInterceptTouchEvent(disallowIntercept);
  if (disallowIntercept) {
    // We should pass "cancel" touch event to make sure controller does not expect
    // any events anymore.
    MotionEvent cancel = MotionEvent.obtain(currentMotionEvent);
    cancel.setAction(MotionEvent.ACTION_CANCEL);
    controller.onInterceptTouch(this, cancel);
    cancel.recycle();
  }
}

代码示例来源:origin: stackoverflow.com

event.setAction(MotionEvent.ACTION_CANCEL);//use this to prevent the keyboard from coming up

代码示例来源:origin: Ramotion/expanding-collection-android

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
  final int actionMasked = ev.getActionMasked() & MotionEvent.ACTION_MASK;
  // Ignore move events if scroll disabled
  if (scrollDisabled && actionMasked == MotionEvent.ACTION_MOVE) {
    return true;
  }
  // Ignore scroll events if scroll disabled
  if (scrollDisabled && actionMasked == MotionEvent.ACTION_SCROLL) {
    return true;
  }
  // Save the event initial position
  if (actionMasked == MotionEvent.ACTION_DOWN) {
    mPosition = pointToPosition((int) ev.getX(), (int) ev.getY());
    return super.dispatchTouchEvent(ev);
  }
  // Check if we are still in the same position, otherwise cancel event
  int eventPosition = pointToPosition((int) ev.getX(), (int) ev.getY());
  if (actionMasked == MotionEvent.ACTION_UP) {
    if (eventPosition != mPosition) {
      ev.setAction(MotionEvent.ACTION_CANCEL);
    }
  }
  return super.dispatchTouchEvent(ev);
}

代码示例来源:origin: stackoverflow.com

clickListener
    .onClick(DrawableClickListener.DrawablePosition.LEFT);
event.setAction(MotionEvent.ACTION_CANCEL);
return false;
clickListener
    .onClick(DrawableClickListener.DrawablePosition.RIGHT);
event.setAction(MotionEvent.ACTION_CANCEL);
return false;

代码示例来源:origin: aa112901/remusic

MotionEvent cancelEvent = MotionEvent.obtain(event);  
cancelEvent  
    .setAction(MotionEvent.ACTION_CANCEL  
        | (event.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT));  
v.onTouchEvent(cancelEvent);

代码示例来源:origin: liaoinstan/SpringView

event.setAction(MotionEvent.ACTION_CANCEL);
MotionEvent ev2 = MotionEvent.obtain(event);
dispatchTouchEvent(event);
ev2.setAction(MotionEvent.ACTION_DOWN);
return dispatchTouchEvent(ev2);

代码示例来源:origin: ksoichiro/Android-ObservableScrollView

event.setAction(MotionEvent.ACTION_DOWN);

代码示例来源:origin: ksoichiro/Android-ObservableScrollView

event.setAction(MotionEvent.ACTION_DOWN);

代码示例来源:origin: ksoichiro/Android-ObservableScrollView

event.setAction(MotionEvent.ACTION_DOWN);

代码示例来源:origin: ksoichiro/Android-ObservableScrollView

event.setAction(MotionEvent.ACTION_DOWN);

代码示例来源:origin: ksoichiro/Android-ObservableScrollView

event.setAction(MotionEvent.ACTION_DOWN);

代码示例来源:origin: umano/AndroidSlidingUpPanel

up.setAction(MotionEvent.ACTION_CANCEL);
super.dispatchTouchEvent(up);
up.recycle();
ev.setAction(MotionEvent.ACTION_DOWN);
ev.setAction(MotionEvent.ACTION_DOWN);

代码示例来源:origin: beworker/pinned-section-listview

event.setAction(MotionEvent.ACTION_CANCEL);
mTouchTarget.dispatchTouchEvent(event);
event.recycle();

代码示例来源:origin: scwang90/SmartRefreshLayout

e.setAction(MotionEvent.ACTION_CANCEL);
    super.dispatchTouchEvent(e);
} else if (mFalsifyEvent != null) {
  mFalsifyEvent = null;
  em.setAction(MotionEvent.ACTION_CANCEL);
  super.dispatchTouchEvent(em);

代码示例来源:origin: robolectric/robolectric

@Test
public void testGetHistorySize() {
 long eventTime = SystemClock.uptimeMillis();
 float x = 10.0f;
 float y = 20.0f;
 float pressure = 1.0f;
 float size = 1.0f;
 motionEvent2.setAction(MotionEvent.ACTION_DOWN);
 assertThat(motionEvent2).hasHistorySize(0);
 motionEvent2.addBatch(eventTime, x, y, pressure, size, 0);
 assertThat(motionEvent2).hasHistorySize(1);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testAccessAction() {
 assertThat(motionEvent1).hasAction(MotionEvent.ACTION_MOVE);
 motionEvent1.setAction(MotionEvent.ACTION_UP);
 assertThat(motionEvent1).hasAction(MotionEvent.ACTION_UP);
}

代码示例来源:origin: liaoinstan/SpringView

resetPosition();
event.setAction(MotionEvent.ACTION_DOWN);
dispatchTouchEvent(event);
isInControl = false;

相关文章