iOS Question (Solved) How to get CustomListView on a page?

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all.

I have a problem. I'm using B4xTabStrip with 3 pages. Each page contains a label, a textfield and customlistview. Each CLV contains B4xSwithes a labels.

Actually it's a schedule for a provider for each day of week. Provider clicks on a day of week in tab strip, selects Yes / No for each shift he wants to work and so on.

Then I need to loop trough each day of week (page of tab strip) collect provider's selections and send it back to the database.

I can populate with a data and it looks Ok. The problem is that I can't find a CLV on tab strop page. I see that I have 3 views as expected, I see a label and text field but not a CLV.

Here is a code I'm using

B4X:
Sub Button1_Click
   
    Try
       
        Dim pg As Page
        Dim n As Int      
        Dim lbl As Label      
        Dim pan As Panel
       
       
        For i=0 To 2
       
            pg.Initialize("")
            pg=TabPages.Get(i)
            pan.Initialize("")
                                   
            n=pg.RootPanel.NumberOfViews
            Log("Title=" & pg.title & " n=" & n)

            txtTest=pg.RootPanel.GetView(0)
            Log("Text=" & txtTest.Text)

            lbl=pg.RootPanel.GetView(1)
            Log("Lbl=" & lbl.Text)      
           
            'Here is when the problem happens
            'How to get a CLV to pass it into GetAnswers sub?
            pan=pg.RootPanel.GetView(2)          
            cvTab1=pan.GetView(0)
                           
            GetAnswers(cvTab1)
           
        Next
   
    Catch
        Log(LastException)
    End Try
   
End Sub

I expected that line pg.RootPanel.GetView(2) will return me CLV but it returns a Panel (see the image)


Please see the attached project.

Thanks.
 

Attachments

  • TabStripTest.zip
    177.4 KB · Views: 268
Last edited:

hatzisn

Expert
Licensed User
Longtime User
Define a variable as a customlistview and point it to the tag property of the customlistview in this tab.

B4X:
Dim clvTemp As CustomListView = pg.RootPanel.GetView(2).Tag

Then access it through this variable.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Define a variable as a customlistview and point it to the tag property of the customlistview in this tab.
But the problem is that I can't find CLV on a tab. I have a working sub that loops trough each item inside CLV but I can't find the CLV itself.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
The clv is not a view but a panel with nested views. You access the panel with the "pg.RootPanel.GetView(2)".

Check again post #2.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Refresh also the browser
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
You can do the same with B4XTabStrip to get the tab.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
You can do the same with B4XTabStrip to get the tab.
her is my code
B4X:
Sub Button1_Click
    
    Try
        
        Dim pg As Page
        Dim n As Int       
        Dim lbl As Label       
        Dim pan As Panel
        
        
        For i=0 To 2
        
            pg.Initialize("")
            pg=TabPages.Get(i)
            pan.Initialize("")
                                    
            n=pg.RootPanel.NumberOfViews
            Log("Title=" & pg.title & " n=" & n)

            txtTest=pg.RootPanel.GetView(0)
            Log("Text=" & txtTest.Text)

            lbl=pg.RootPanel.GetView(1)
            Log("Lbl=" & lbl.Text)       
            
            'Here is when the problem happens
            'How to get a CLV to pass it into GetAnswers sub?
            
            Dim clvTemp As CustomListView = pg.RootPanel.GetView(2).Tag
            
            Log("clvTemp=" & clvTemp) 'returns nothing
            Log("clvTemp=" & clvTemp.Size) 'crashes - Method not found: _getsize, target: 
            
            GetAnswers(clvTemp)
            
        Next
    
    Catch
        Log(LastException)
    End Try
    
End Sub
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Check in the layout if the order of the customlistview is third. Can you please point me to where you have downloaded the B4XTabStrip?

Is it any of these:
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Please see attached screenshots for layout and for TabStrip


Libraries I'm using
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
This is iTabStrip you are referring to. Not B4XTabStrip. You got me confused. Your code looks correct if TabPages is the list you set in the TabStrip.SetPages. I do not know what is going wrong. Maybe you should get some help from @Erel. Are you sure that the TabPages List is a global variable and that you have loaded in every page the corresponding layout? If I were you though I would shift to a B4X custom view like the ones above or the Wobble Menu which will render your code cross platform and not iOS only.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Besides my previous post (#10) please mind what is written in post #8 about the views order in the layout.
 
Upvote 0

Alex_197

Well-Known Member
Licensed User
Longtime User
Besides my previous post (#10) please mind what is written in post #8 about the views order in the layout.


Problem solved.

All I did is directly refenced CLV without looking for it on a page because it's already part of layout.


B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private MainPage As Page
    Private XUI As XUI,label As Label
    Private TabStrip1 As TabStrip
    Private txtTest As TextField
    Private TabPages As List
    Private ScheduleList As List
    Private txtTab2 As TextField
    Private txtTab1 As TextField
    Private txtTab3 As TextField
    Private cvTab1 As CustomListView
    Private cvTab2 As CustomListView
    Private cvTab3 As CustomListView
    Private Answers As String,Tags As String

End Sub
B4X:
Sub Button1_Click
    
    Try
        
        Dim pg As Page
        Dim n As Int
        Dim lbl As Label
        Dim pan As Panel
        
        
        For i=0 To 2
        
            pg.Initialize("")
            pg=TabPages.Get(i)
            pan.Initialize("")
                                    
            n=pg.RootPanel.NumberOfViews
            Log("Title=" & pg.title & " n=" & n)

            txtTest=pg.RootPanel.GetView(0)
            Log("Text=" & txtTest.Text)

            lbl=pg.RootPanel.GetView(1)
            Log("Label=" & lbl.Text)
                        
            Log(cvTab1.Size)
                        
            If i=0 Then
                GetAnswers(cvTab1)
            Else If i=1 Then
                GetAnswers(cvTab2)
            Else If i=2 Then
                GetAnswers(cvTab3)
            End If
        Next
    
        Msgbox(Answers & CRLF & Tags,"UU")
    
    Catch
        Log(LastException)
    End Try
    
End Sub

Thank you your help.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…