Android Question solved: clear Labels on TabStrip

anOparator

Active Member
Licensed User
Longtime User
This works with simple 1 activity project:
B4X:
Sub Button1_Click
	For Each vw As View In Activity
		' check its type
		If vw Is Label Then
			'			labl = vw
			Dim labl As Label
			labl = vw
			labl.Visible = False
			' need object with correct type so
			' can gain access to properties
			' make copy of original view
			'			labl.Visible = False
			'			labl = vw
			'			Log (btn.Text)
		End If
	Next

End Sub
How to clear 4 Labels on , TabStrip1.LoadLayout("Page1", "PAGE 1")
 

Attachments

  • tmp_clearTabStrip2635851.zip
    12.2 KB · Views: 147

DonManfred

Expert
Licensed User
Longtime User
1. You did forget to add
#AdditionalJar: com.android.support:support-v4
to your project (asuming you are using b4a 6+)
2.
B4X:
Sub TabStrip1_PageSelected (Position As Int)
    Log($"Current page: ${Position}"$)
    If Position = 0 Then
        For Each v As View In Activity.GetAllViewsRecursive
            'Log(GetType(v))
            If v Is Label Then
                Dim labl As Label
                labl = v
' Do with labl what you want. Set it visible, change the text....
                'labl.Visible = False
                labl.Text = "TEXT"
            End If    
        Next
    End If
End Sub

3. Additionally you can use the Tag of the labels to distinguish them. Or to identify them to know which one to change...
 
Last edited:
Upvote 0

anOparator

Active Member
Licensed User
Longtime User
I like GetAllViewsRecursive but it really does get all of the selected type and hide every label on every Tab, is there something similar for the selected Views on Page1 only?
As in:
For Each v As View In Page1.GetAllViewsRecursive

thanks for the example, I have put the 4 Labels of Page1 on a Panel, renamed the Button because of a duplicate name on another Tab, and am using:
Sub Button_Click
Panel2.Visible = False
End Sub

also added #AdditionalJar
 
Upvote 0
Top