如何获取列表视图项 onTouch 方法? [英] How to get List View Item onTouch method?
问题描述
我有一个 ListView,我想对列表项执行拖放操作.我正在覆盖具有两个参数的 onTouch
方法
I have a ListView and I want to perform Drag and Drop on list items. I am Overridding a onTouch
method which has two parameters
@Override public boolean onTouch(View view, MotionEvent me) {}
在视图中我得到了完整的 ListView.如何在按下哪个键时获得特定的 TextView?
In view I am getting complete ListView. How can i get perticular TextView on which key is pressed?
如果我长按并获得该视图,但我不想执行长按操作,我可以拖动项目.
I am able to drag items when if I long press and get that view but i dont want to perform long press action.
有什么方法可以在 onTouch
中获取所选项目的位置?
Any way to get selected item position in onTouch
?
推荐答案
一种方法是实现一个自定义 Adapter
,您可以使用它来填充您的 ListView
.在 Adapter
的 getView
方法中,您可以在您创建的视图上调用 setOnClickListener
,并以这种方式添加项目点击侦听器.
One way is to implement a custom Adapter
which you use to populate your ListView
. In the getView
method of your Adapter
you can call setOnClickListener
on the view that you create, and add an item click listener that way.
setOnClickListener of a ListView not working.
这篇关于如何获取列表视图项 onTouch 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!