Android: Create a swipe gesture event programmatically

冷暖自知 提交于 2019-12-06 02:09:32

问题


I've been trying to find an answer for this specific case on Google and amazingly couldn't find it anywhere (there's just answers about detecting, not creating, swipes). I want to actually 'run' a simulated swipe from right to left on the screen (doesn't matter where, but ideally from the right edge to the left). I tried something like this, but I get a NPE:

final float viewWidth = view.getWidth();
    TouchUtils.drag(null,viewWidth,1f,0f,0f,1);

The reason? I need to force a swipe to the next page in an infinite viewpager which has no real reference to the page position (so I can't just use setCurrentItem).

Any ideas?

来源:https://stackoverflow.com/questions/30563169/android-create-a-swipe-gesture-event-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!