Android Question [solved]How to get the top distance value of the item in listview

Syd Wright

Active Member
Licensed User
I don't think this is possible with a regular listview. Even if you would be able to determine the top, then the result will not look nice due to lag: As soon as the user scrolls through the list, the picture (or other object) that you have placed on top of it will not move instantly. The top will continuously and rapidly have to be recalculated.
Better to use a custom listview or better still: XCustomListview:


Licensed User
i find a function "getSelectedView" in android.
getSelectedView added in API level 1
public View getSelectedView ()
View The view corresponding to the currently selected item, or null if nothing is selected

Can this function be applied to listview?
Last edited:


Well-Known Member
Licensed User
Another option would be to use xCustomListView. You could have a secondary view on the item layout for display which is set invisible.
On list selection click you then show the hidden view.

see attached sample .. I have included a variable to keep track of previously selected item to hide last displayed message.

alternatively, you could just programmatically add the label / view to the list panel at selection.