How to best handle fling gesture for Android ListActivity

半城伤御伤魂 提交于 2019-11-30 05:24:40
emmby

Try using AbsListView.pointToPosition() to determine the list item for the X,Y coordinate in your list view.

If you're using the recipe from #937313, you should be able to override onFling() more or less as follows:

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
    try {
        Toast.makeText(listAdapter.getItem( listView.pointToPosition( (int) e1.getX(), (int) e1.getY() ).toString() );
        return super.onFling();
    } catch( Exception e ) {
        // do nothing
    }
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!