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

Maodge

Member
Licensed User
hi,
In my app, i want to dispaly somthing on the right of select item like the attached pic shows.
so i must get the value of the select items' distance from the top.
i find in B4A lib,and read listview doc https://developer.android.google.cn/reference/android/widget/ListView of android.
I have got no idea how to get that distance value.
how to get the distance value?
Thanks
 

Attachments

  • lv_single.png
    lv_single.png
    22.7 KB · Views: 267

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:
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime 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

  • xCLV sample.zip
    16.4 KB · Views: 266
Upvote 0
Top