Android ListView with multiple onclick listener and GestureDetector -
I am using a gesture detector for the first time on the list view. This works fine for me unless I have click on more than one click on the list view object. I want a gesture detector for the entire list but it is not working, where I have the onclick event for some item in the list view.
Consider my code:
& lt; LinearLayout xmlns: android = "Http://schemas.android.com/apk/res/android" Android: Android: Android: Android: Leaut_vind = "Mac_perent" Android: Leaut_heit = "wrap-content" android: orientation = "horizontal "Android: weightSum =" 100 "Android: background =" #FFFFF "& gt; & Lt; TextView android: id = "@ + id / meet_time" Android: layout_width = "0dp" Android: Layout_height = "Match_parent" Android: textcolor = "# FFFFFF" android: gravity = "center" Android: TextAppearance = "Android: Attr / TextAppearanceSmall "android: background =" # ef3d4a "android: textStyle =" bold "Android: layout_weight =" 30 "Android: text =" @ string / note "/> & Lt; TextView android: id = "@ + id / textid" Android: layout_width = "0dp" Android: Layout_height = "Match_parent" Android: textcolor = "# FFFFFF" android: gravity = "center" Android: TextAppearance = "android: attr / TextAppearanceSmall "Android: background =" # ef3d4a "Android: Text-style =" bold "Android: layout_weight =" 30 "Android: text =" @ string / note "/> & Lt; LinearLayout Android: layout_width = "0dp" Android: Layout_height = "Wrap_content" Android: Layout_gravity = "center" android: orientation = "horizontal" android: layout_weight = "10" & gt; & Lt; imageView android: id = "@ + id / arrow_icon" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" android: src = "@ drawable / down" / & gt; & Lt; imageView android: id = "@ + id / delete_icon" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: visibility = "" Gone Android: src = "@ drawable / icon_delete_red" / & gt; & Lt; / LinearLayout & gt; & Lt; / LinearLayout & gt;
For textave and meet_time, I set the oncliclist, when I want to hit this lesson, it does not work. For the gesture detector, I have expanded the SimplonJestor Listener.
Please suggest me please.
You first need to understand how to OnTouch
work for events .
First thing first, OnClickListener
OnTouchListenter
is a personal matter and what does it do below
and above
Touch event listens if a touch event is "handled" by a certain audience on a certain view, then the listener returns true which prevents an event that promotes "normal" scenes That is what it covers / keeps.
What happens in your case that OnClickListener
handles the event and does not give ListView
to get the touch event. You can potentially implement your own OnClickListener
which is different from the standard only by which he searches for it to give false
for the click is.
You must limit your ListView
and implement the onInterceptTouchEvent
this ListView
GestureDetector
and handles accordingly)
Public class expands MyListView list view {@ Override Public Boolean on Intercept Touch Event (Motion Event Eve) {// through your Gesture Detector If (ev.getActionMasked ()! = ACTION_DOWN & amp; amp; amp; yourGestureDetector.onTouchEvent (ev)) {// You have detected your gesture // ....} Return False; // Return is false so that the child will continue to receive touch events in the text view}}
Hope this helps.
Comments
Post a Comment