Android Question ULV Get an object a row in a Panel without a click event

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Hello @Informatix . How can I get the reference for a single item in an ULV without needing to get a click event feedback. For example:

Panel1 = ULV.get(I) -> where panel is the parent that contains the element in index I of ULV...

Suppose that the row contains an image and a label... then

img1 = panel1.get(0)
lbl1 = panel.get(1)

I didn't find anything like this in ULV description... this could be used to, for example, add an alert in a row in ULV or update some data in response of an event in a service. How can I do this... is there any way?
 

johndb

Active Member
Licensed User
Longtime User
Hello @Informatix . How can I get the reference for a single item in an ULV without needing to get a click event feedback. For example:

Panel1 = ULV.get(I) -> where panel is the parent that contains the element in index I of ULV...

Suppose that the row contains an image and a label... then

img1 = panel1.get(0)
lbl1 = panel.get(1)

I didn't find anything like this in ULV description... this could be used to, for example, add an alert in a row in ULV or update some data in response of an event in a service. How can I do this... is there any way?
Why not just reload the content using:
B4X:
ulv.RefreshContent
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Ok, but I want to update ONE object of one row. How do I reference the object in a row to update that? When clicked, I get the sender panel in the event, ok! But if I receive an event from a service telling to change the value of a text in a row (for example, second object in third row)...
I can't do label = panel.get(1) because I don't have the reference...will I need to reload the ENTIRE ULV and after refresh? Doesn't look to be an efficient way.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
try this:
B4X:
Sub ULV_ItemClick(ItemID As Long, Position As Int, ClickedPanel As Panel)
    Dim lbl As Label = ClickedPanel.GetView(0)
    lbl.Text = "New Name"
End Sub

You can get and update the content of the object in ULV clicked.

One tip: you will not to get support from Informatix to ULV in the forum. The support is only by e-mail.
 
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
Ok @asales , thanks! That is the problem. I really didn't find a way to get the panel in, for example, row number 5, without receiving a click event! Imagine that my server sent to me an update of some user information that is stored in row 5 of the ULV. How can I do the update in row 5? How can I get the panel without the click event? I don't know! I found a workaround: store the panel contents is a database and, when receiving an update request by a service for example find the list row using a query in that database and the call the method ULV.UpdateLayout("layout",rowid) ... the row will change without entire list refresh but it's so much far to be an elegant way for programming. Looks more like an improvisation! I already have the list content data in the list itself! Why do I have to duplicate that? And even if I already have duplicated, why can't I do a getpanel (Dim pnl1 as panel = ULV.getpanel(5)) like in custom listview?
 
Upvote 0

johndb

Active Member
Licensed User
Longtime User
Ok @asales , thanks! That is the problem. I really didn't find a way to get the panel in, for example, row number 5, without receiving a click event! Imagine that my server sent to me an update of some user information that is stored in row 5 of the ULV. How can I do the update in row 5? How can I get the panel without the click event? I don't know! I found a workaround: store the panel contents is a database and, when receiving an update request by a service for example find the list row using a query in that database and the call the method ULV.UpdateLayout("layout",rowid) ... the row will change without entire list refresh but it's so much far to be an elegant way for programming. Looks more like an improvisation! I already have the list content data in the list itself! Why do I have to duplicate that? And even if I already have duplicated, why can't I do a getpanel (Dim pnl1 as panel = ULV.getpanel(5)) like in custom listview?
ULV doesn't store the information. It is cached in order to make it efficient. Why not store your information in a local database and load the data into ULV? If you need to store the information in the list itself then I would recommend you using the standard listview.
 
Last edited:
Upvote 0

Marcos Alves

Well-Known Member
Licensed User
Longtime User
thanks @johndb ! I decided to do the composite solution using a database mirroring the data that I eventually will need to index the row number of ULV (and then, update layout of this). It looks to be fast, memory saver and easy to code.
 
Upvote 0
Top