B4J Question Edit Button text from code

hakha4

Member
Licensed User
Sorry to ask so many questions but the deeper you get in to this amazing program suite the number of questions increases ! I wan't to set button text property from code when data changes in a SqLite table. The buttons are created in designer. I know this can be done in a class creating buttons at run-time but this make's it trickier with correct placing the buttons on a Pane. Why is the TEXT property not exposed when getting a node as in code below ?
B4X:
Sub SetButtonText
    '### Update button text when record changes ###
Dim x As Int = 0
Dim tmpSQL As String
Dim ls As List
    ls.Initialize
    tmpSQL = "Select * FROM RF_codes"
    Dim rs As ResultSet = SQL1.ExecQuery(tmpSQL)
    Do While rs.NextRow
        ls.Add(rs.GetString("Device")) ' add Button text from table to list
    Loop
   
    For Each n As Node In Pane_selectButton.GetAllViewsRecursive
        If n Is Button Then' set Button text from list
            n.TEXT = ls.Get(x)' NO SUCH PROPERTY TEXT! Workaround ??
            Log(n.Tag)
            x=x+1
        End If
       
    Next


End Sub
Is it doable ?
Any help appreciated
 

Daestrum

Well-Known Member
Licensed User
You could probably change (not tested though)
B4X:
    For Each n As Node In Pane_selectButton.GetAllViewsRecursive
        If n Is Button Then' set Button text from list
            n.TEXT = ls.Get(x)' NO SUCH PROPERTY TEXT! Workaround ??
            Log(n.Tag)
            x=x+1
        End If
       
    Next
to
B4X:
    For Each n As Node In Pane_selectButton.GetAllViewsRecursive
        If n Is Button Then' set Button text from list
            dim tempButton as Button = n
            tempButton.Text = ls.Get(x)' NO SUCH PROPERTY TEXT! Workaround ??
            Log(n.Tag)
            x=x+1
        End If
       
    Next
 
Top