I have a ListView showing in each row three things (left icon, middle text, right icon). When the user “clicks” on a row, I want to do an action depending on the horizontal position of the “click”, but there’s no x-coordinate in AdapterView.OnItemClickListener.onItemClick nor do I have any idea what to do instead.
I don’t need the exact coordinate, an information like “left/middle/right” would suffice. Knowing which of the three things was touched is about the same. I’ve found this answer, but I doubt it’s related. Is it? Is there a way how to get the x-coordinate?
Or should I try GridLayout?
If you want to get the exact coordinates of a click, you need to set
onTouchListenerinstead on the view that you want receive events for.From this, you’ll get the
MotionEventwhich you can use to figure out the coordinates and pretty much anything else you’d want to know.