B4J Question How to set a Blank value into all B4XFloatTextFields in a Form

NamR

Member
Licensed User
Hi everyone,

I have a Form and I want to set Blank ("") value into all B4XFloatTextFields.

I try this code
B4X:
                            For Each n As Node In f.RootPane.GetAllViewsRecursive
                                If n Is B4XFloatTextField Then
                                    Dim nJo As JavaObject = n
                                    nJo.runmethod("setText",Array(""))
                                End If
                            Next

But I am getting this error

Compiling generated Java code. Error
B4J line: 878
If n Is B4XFloatTextField Then
src\rtm\b4j\arap\main.java:2290: error: incompatible types: Node cannot be converted to b4xfloattextfield
if (_n.getObjectOrNull() instanceof b4xfloattextfield) {
^
1 error

Thank you in advance.
 

NamR

Member
Licensed User
Completely wrong solution.

Correct solution:
B4X:
For Each n As B4XView In f.RootPane.GetAllViewsRecursive
    If n.Tag Is B4XFloatTextField Then
        Dim txt As B4XFloatTextField  = n.Tag
        txt.Text = ""
    End If
Next

Hi Erel,

Thank you for correcting my implementation.

Cheers...
 
Upvote 0
Top