Android Question How do I iterate over b4xfloattxtfields in xCustomlistview

Hilton

Active Member
Licensed User
Longtime User
Hi,

I have been learning how to use the b4xtable and b4xcustomlistview.

Initially, in the expanded form of the xCustomListview I was using labels, buttons and edittexts and was able to iterate over the items in the panel associated with the selected item in the list and store them in a map - the key being the TAG field and the value being the object (label etc). Using that map I was able to get and set the text values of the fields that belonged to any item in the xCustomListView list.

Fine, but I liked the economy of space of the b4xFloatTextField so I used them instead, but it does not work the same. Would someone kindly point me in the right direction as I would like to try to use cross platform code as much as possible.

Thank you.
 

DonManfred

Expert
Licensed User
Longtime User
Where is the projectupload which shows the issue?
 
Upvote 0

Hilton

Active Member
Licensed User
Longtime User
It should work like this:
B4X:
Dim ft As B4XFloatTextField = clv.GetPanel(0).GetView(2).Tag 'get the field from the first item assuming that the field is the third view in the layout.

Thanks for that, but that was pretty much what I was trying. As an experiment I took the B4A_ExpandableList and:
1. removed the customlistview module and used XUI VIEWS instead.
2. added a B4XFloatTextField to the pnlExpanded panel in the designer.
3. gave all items in the pnlExpanded a tag (eg et1,btn1,ft etc.....)
4. added this code at the end of Sub ExpandItem so that it looks like this
B4X:
Sub ExpandItem (index As Int)
    Dim id As ItemData = clv1.GetValue(index)
    clv1.ResizeItem(index, id.ExpandedHeight)
    clv1.GetPanel(index).Tag = True
    AnimatedArrow(index, 0, 180)
    '-------test code-------
    pnlExpanded = clv1.GetPanel(index).GetView(1)
    Log(pnlExpanded.Tag)
    For i = 0 To pnlExpanded.NumberOfViews - 1
        Dim x As B4XView = pnlExpanded.Getview(i)
        Log(x.Tag)
    Next
End Sub

5. the results were fine(with the correct tag names showing) for all views but the B4XFloatTextField which listed a whole lot of stuff I do not understand. I was hoping to just get the tag.

I am not certain if anything is wrong or if the problem is me with my lack of understanding. In any event help would be appreciated.
 
Upvote 0

Hilton

Active Member
Licensed User
Longtime User
It will be useful to add Log(GetType(x.Tag))

B4X:
For x As b4XView In pnlExpanded.GetAllViewsRecursive
 If x.Tag Is B4XFloatTextField Then
  Dim ft As b4XFloatTextField = x.Tag
  Log(ft.Tag)
 Else
  Log(x.Tag)
End If
Next

That has done the trick. Knowing that the initial tag is the object is useful. The question is, will that be consistent across all XUI VIEWS?

Thank you for your help.
 
Upvote 0
Top