Android Code Snippet Set value to single view on specific TabStripViewPager panel

On a TabStripViewPager with more than 1 loaded layout the views defined in Sub Global are only valid for the last loaded panel. Change of values on previous loaded panels require some extra effort.

With this code you can access a specific view on any tabstrip control panel by using Erel's RemovePage function.

"RemovePage" gives the panel of a specific Tabstrip page back. This panel can be iterated to find a special tag to locate the wanted view. After changes made the updated panel can be brought back to the old place via "InsertPage".

B4X:
Sub raSetSingleValueToViewOnCurrentTabstripPanel(tabstripX As TabStrip, strTagBeg As String, strValue As String) As Boolean
    Dim bolRet As Boolean = False
    Dim intActPage As Int = tabstripX.CurrentPage
    Dim strTitle As String = GetTabText(tabstripX, intActPage)
    Dim panPage As Panel = RemovePage(tabstripX, intActPage)
    For Each v As View In panPage.GetAllViewsRecursive
        Select Case True
            Case v Is Label
                Dim lblX As Label = v
                Dim x As String = lblX.Tag & ""
                x = x.Trim.ToLowerCase
                Select Case True
                    Case x.StartsWith(strTagBeg.Trim.ToLowerCase)
                        lblX.Text = strValue
                        bolRet = True
                        Exit
                End Select
        End Select
    Next
    InsertPage(tabstripX, intActPage, panPage, strTitle)
    tabstripX.ScrollTo(intActPage, False)
    Return bolRet
End Sub

Attached testproject might help to understand the basic usage.
07-05-_2018_13-15-53.png


If there is a significant simpler way to access a specific view on a specific tab I would be delighted to learn from an updated testproject.
 

Attachments

  • TabStripSingleViewChange.zip
    10.2 KB · Views: 212
Top