iOS Question XUI xCustomListView Manipulation - Solved

RichardN

Active Member
Licensed User
I have an application using the xCustomList View. Each cell is populated using one of about 8 different layouts. Each layout contains a different combination of views most importantly Labels, TextViews and TextFields.

I wish to clear text in certain members of the views in cells where those views are present... all in one go using a button_click event. It has occurred to me that the easiest way to do that would be to preset the Tag property of the subject views to a certain value and then check for that value by iterating through the containing panels and their views.
 
Last edited:

RichardN

Active Member
Licensed User
It is a little confusing using cross-platform modules as to which object types might be XUI as which might be traditional types. In the end this seems to work:

There may well be a slicker way of operating on groups of views - I am open to suggestions....
B4X:
Private Sub MessageBox_Click(ButtonText As String)
    
    If ButtonText <> "OK" Then Return
    
    'Clearing certain groups of child views in an xCustomListView
    'but only those designated by the presence of a 'clearme' tag
    
    Dim p As B4XView
    Dim index As Int

    For index = 0 To CustomListView1.Size -1
        
        p = CustomListView1.GetPanel(index)
        
        For Each View As B4XView In p.GetAllViewsRecursive
            
            If View Is Label And View.Tag = "clearme" Then View.Text = ""
            If View Is TextField And View.Tag = "clearme" Then View.Text = ""
            If View Is TextView And View.Tag = "clearme" Then View.Text = ""
            
        Next
        
    Next
    
End Sub
 
Upvote 0

RichardN

Active Member
Licensed User
Thanks Erel.

That works because all the views of type B4XView have a .Text property. I was a little scared of returning one that did not... and throwing an exception.
 
Upvote 0
Top