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:
https://www.b4x.com/android/forum/threads/b4x-xui-xcustomlistview-cross-platform-customlistview.84501/
 

Maodge

Member
Licensed User
i find a function "getSelectedView" in android.
java.lang.Object
↳android.view.View
↳android.view.ViewGroup
↳android.widget.AdapterView<android.widget.ListAdapter>
↳android.widget.AbsListView
https://developer.android.google.cn/reference/android/widget/AbsListView
getSelectedView added in API level 1
public View getSelectedView ()
Returns
View The view corresponding to the currently selected item, or null if nothing is selected

Can this function be applied to listview?
Thanks
 
Last edited:

mangojack

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.
 

Attachments

Top