如何获取列表视图项onTouch方法? [英] How to get List View Item onTouch method?
问题描述
我有一个ListView和我想要执行拖放列表项。我Overridding一个 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
@覆盖公共布尔onTouch(查看视图,MotionEvent我){}
鉴于我收到完整的ListView。我怎样才能在哪个键是pressed perticular TextView的?
In view I am getting complete ListView. How can i get perticular TextView on which key is pressed?
我可以,如果我长的preSS时,将项目,并获得这个观点,但我不希望执行长preSS行动。
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
?
推荐答案
一种方法是实现一个自定义适配器
您可以用它来填充你的 ListView控件
。在 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.
还有就是这<一一些示例code href="http://stackoverflow.com/questions/3402255/setonclicklistener-of-a-listview-not-working">setOnClickListener一个ListView不灵。
这篇关于如何获取列表视图项onTouch方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!