Android Question [B4X Xui Views] GetAllViewsRecursive from B4XFloatTextField

Sergio Medice Garcia

Member
Licensed User
Hi To all,

i trying to get all B4XFloatTextField from my activity to change all LargeLabelTextSize at once.
But if a use GetAllViewsRecursive he get the labels and edittexts from the activity, not the B4XFloatTextField View.

I used this code to check all views:

B4X:
For Each v As View In PnlCadastro.GetAllViewsRecursive
                
    If v Is EditText Then
        Log("Is edittext")
    End If

    If v Is Label Then
        Log("Is label")
    End If

    If v Is B4XFloatTextField Then
        Log("Is B4XField")
    End If

Next

And the result is the image attached.
I attached the layout of my panel/activity too...

Would anyone know how i would get B4XFloatTextField LargeLabelTextSize property?

Thanks for advance
 

Attachments

  • b4x_logs.PNG
    b4x_logs.PNG
    7.5 KB · Views: 228
  • Screenshot_2020-02-06-10-48-38.png
    Screenshot_2020-02-06-10-48-38.png
    98.4 KB · Views: 204

Jorge M A

Well-Known Member
Licensed User
Please check this way:

B4X:
    For Each v As View In Activity.GetAllViewsRecursive
        Log(v.Tag)
        If v.Tag Is B4XFloatTextField Then
            Log("Yes! It is!...")
        End If
    Next
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Just to ensure a more complete response for you to achieve the goal you set:
B4X:
        For Each v As View In Activity.GetAllViewsRecursive

            If v.Tag Is B4XFloatTextField Then
                Dim te As B4XFloatTextField = v.tag
                te.LargeLabelTextSize = 12 'Set desired size here
                te.Update
            End If

        Next
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The above post shows the correct way to do it.
All XUI Views custom views assign themselves to the base panel Tag property. The code looks like this:
B4X:
Public Sub DesignerCreateView (Base As Object, lbl As Label, Props As Map)
    mBase = Base
    Tag = mBase.Tag
    mBase.Tag = Me

mBase is the panel that gets added to the views tree.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
The above post shows the correct way to do it.
All XUI Views custom views assign themselves to the base panel Tag property. The code looks like this:
B4X:
Public Sub DesignerCreateView (Base As Object, lbl As Label, Props As Map)
    mBase = Base
    Tag = mBase.Tag
    mBase.Tag = Me

mBase is the panel that gets added to the views tree.
This if you create that custom view!

I think that many times GetType is very useful.
 
Upvote 0

Sergio Medice Garcia

Member
Licensed User
Please check this way:

B4X:
    For Each v As View In Activity.GetAllViewsRecursive
        Log(v.Tag)
        If v.Tag Is B4XFloatTextField Then
            Log("Yes! It is!...")
        End If
    Next

This method solved for me to find which view is in fact B4XFloatTextField, however it did not solve my problem because when trying to change the properties I get an error stating that the type of the view is not B4XFloatTextField so I can later access its properties

Is there another way for me to access the properties of B4XFloatTextField without being the same as I did in the print?
 

Attachments

  • erro1.PNG
    erro1.PNG
    28 KB · Views: 232
  • metodo_recursive.PNG
    metodo_recursive.PNG
    7.2 KB · Views: 206
Upvote 0

Sergio Medice Garcia

Member
Licensed User
Please post your logs as text.
Please post your code.

It seems your code is wrog here:
B4X:
Dim a As B4XFloatTextField = v

you must use v.tag, here is where View is stored.
B4X:
Dim a As B4XFloatTextField=v.tag

Thanks man, this solved.
 
Upvote 0
Top