0

How can i find the particular selected item from the list used in the swipe action in order to make my changes to... I know how to detect swipe actions already using the onTouchListener and onItemClickListener.... from Swipe action on a List Item? ...

but my problem here is how to match the action with one of the items onItemClickListener auto-matches to the selected item onTouchListener provides a general action for all over the list

Community
  • 1
  • 1
SoliQuiD
  • 2,093
  • 1
  • 25
  • 29

1 Answers1

0

The View parameter in your onTouch method is the list item. So in this example, under the onTouch method, where is says Log.i(logTag, "Swipe Left to Right"); it's saying that the list item has had a left-to-right gesture done on it. Does that help?

Community
  • 1
  • 1
MSpeed
  • 8,153
  • 7
  • 49
  • 61
  • As i understand that the View parameter in public boolean onTouch(View v, MotionEvent event) is the listitem being processed.... if thats write then how can i control this particular item from my custom adapter (i need an index or something) Thanks anyway @billynomates – SoliQuiD Jun 18 '14 at 11:54
  • @SoliQuiD You should always control the item from your ListView which should implement onClickListener and onLongClickListener (or use and anonymous innter class). See where it says "2nd I use the swipe detector class in the list view:". You are setting your onTouchListener as your new SwipeDetector class, then when the listitem is clicked or long-clicked, you check if the SwipeDetector.swipeDetected() returns true. – MSpeed Jun 18 '14 at 12:12
  • WOWW.... thanks soo much for that... it was driving me crazy. so iv used the swipe detector from inside the onClickItemListener to use the clicked item as reference in the onTouch ... SOLVED :) – SoliQuiD Jun 18 '14 at 13:35
  • and if i can ask for ur opinion @billynomates with this simple question about the link ur referenced to... http://stackoverflow.com/questions/4373485/android-swipe-on-list/9340202#9340202 i cant see that it matters if i returned true or false in the onTouch method u can use this thread http://stackoverflow.com/questions/24287292/returning-true-and-false-in-ontouch – SoliQuiD Jun 18 '14 at 13:47