views:

60

answers:

2

Hey,

my friend and i develop a Android programm.

Now we got to the question if it's possible to get the actual position of an ListElement.

Example: You drag the list up and down, and now you want to konw which element is on the center of the screen?

can anyone help us?

A: 

There's a function AbsListView#pointToPosition which will return the position in the adapter for the child view at the specified point. You can probably call that with half the height and width of the ListView to get the position for the center item. There is also AdapterView which is one of the parents of ListView that has some functions for returning item positions.

Qberticus
+1  A: 

you can use the ListView functions

getFirstVisiblePosition() 

and

getLastVisiblePosition()

so you can calculate whats element on the center of the screen.

Jorgesys