Skip to content Skip to sidebar Skip to footer

Items In ListView Not Long Clickable After Setting Click Listener In GetView()

I've searched around and have not come out with a solution (maybe not using the correct keywords). So, I've a custom ListView which its item can be dragged around when the item is

Solution 1:

I think that a gesture detector is one of ways to handle events. Usually, however, a gesture detector is used when we want to detect a gesture not a long-press.

The reason why onItemLongClick isn't called is that onClickListener might consume a touch event. In that reason, if you want to handle onItemLongClick, intercept touch event and dispatch it to views you want to handle.

You can find more details following link. http://developer.android.com/guide/topics/ui/ui-events.html


Solution 2:

Ok, just found out the solution myself. Instead of using onItemLongClickListener, I create a gesture detector to detect for long press. Then I override dispatchTouchEvent and force to scan for long press first, then return super.dispatchTouchEvent and the other following touch events. Suggestions are still welcomed!


Post a Comment for "Items In ListView Not Long Clickable After Setting Click Listener In GetView()"