I am trying to get position inside a fling for a listview. No matter what item I fling on, I get -1 return value. I verified that the x,y coordinates from the event are fine. Any ideas on why that might be happening?
Here is my code:
super.onCreate(savedInstanceState);
setContentView(R.layout.application_list_view);
listView = getListView();
int x = (int)(e1.getX());
int y = (int)(e1.getY());
int pos = (int) listView.pointToPosition(x, y);
Thanks for help.
I think you’re missing code to setup the gesture listener and fling event handler. You’ll be able to get the position when you’re handling the event, not on create.
The answer in this other post shows you how: Gesture in listview android