android MotionEvent.obtain模拟事件,自动触发
2013-03-10 21:16
417 查看
view.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { Toast toast = Toast.makeText( getApplicationContext(), "View touched", Toast.LENGTH_LONG ); toast.show(); return true; } }); // Obtain MotionEvent object long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis() + 100; float x = 0.0f; float y = 0.0f; // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState() int metaState = 0; MotionEvent motionEvent = MotionEvent.obtain( downTime, eventTime, MotionEvent.ACTION_UP, x, y, metaState ); // Dispatch touch event to view view.dispatchTouchEvent(motionEvent);
相关文章推荐
- android中MotionEvent.ACTION_CANCEL事件如何被触发?
- android中MotionEvent.ACTION_CANCEL事件如何被触发?
- android中MotionEvent.ACTION_CANCEL事件如何被触发?
- android中MotionEvent.ACTION_CANCEL事件是什么意思,如何触发
- android中MotionEvent.ACTION_CANCEL事件如何被触发?
- android中MotionEvent.ACTION_CANCEL事件如何被触发?
- android中MotionEvent.ACTION_CANCEL事件如何被触发?
- 天天记录 - Android Touch事件学习 - 修改MotionEvent的值
- Android中触摸事件MotionEvent的来源
- Android模拟、实现、触发系统按键事件的方法
- 利用js的trigger函数,模拟事件的自动触发
- Android的MotionEvent和事件处理
- Android模拟、实现、触发系统按键事件的方法
- Android 笔记 motionEvent 处理触摸事件
- Android之触摸事件MotionEvent
- Android学习记录:MotionEvent,onTouch,OnTouchListener 事件机制等学习
- Android 使用 sendevent 模拟鼠标和键盘事件
- Android事件触发EditText焦点和自动弹出键盘
- Android通过事件触发EditText焦点和自动弹出键盘
- Android 代码模拟触发事件总结