iOS Question Cant get index of CLV with iTabstrip

salvadoro

Member
Licensed User
Longtime User
Hi i need help cause i can't get the elements of the panel of CLV used with iTabstrip
This is the code i use

B4X:
Dim index As Int : index=0
For Each colmenus As Map In menus

    'Create the page
    Dim categoria As Page
    categoria.Initialize(category)
    categoria.RootPanel.LoadLayout("tab_menu")
    categoria.Title = category

    Dim dishes As List = colmenus.Get("dishes")
    For Each coldishes As Map In dishes

        Dim price As Int = coldishes.Get("price")
        Dim name As String = coldishes.Get("name")
        Dim description As String = coldishes.Get("description")
        Dim dishLink As String = coldishes.Get("dishLink")
        Dim dishCode As String = coldishes.Get("dishCode")

        ' Add dish into the list
        clvMenu.Add(CreateListItem(dishCode, name, description, price, index), dishCode)
        index = index + 1
    Next
   
    'Add the page to the tab
    TabPages.Add(categoria)

Next



Sub CreateListItem (DishCode As String, DishName As String, DishDescription As String, DishPrice As Double, Index As Int) As Panel
    Dim pnlItem As Panel
    pnlItem.Initialize("")
    pnlItem.Width = clvMenu.AsView.Width
    pnlItem.Height = 90dip
    pnlItem.LoadLayout("menu_item")
    pnlItem.Tag = Index & "=" & DishCode

    'Write the info
    lblName.Text = DishName
    lblName.Tag = DishCode
    lblDescription.Text = DishDescription
    lblPrice.Text = DishPrice
    lblPrice.Tag = Index
    lblItems.Tag = Index
    btnMas.Tag=Index
    btnMenos.Tag=Index
   
    Return pnlItem
   
End Sub

The example is:

tsMenu with 3 tabs mean 3 pages
Page1 with 8 elements in the CLV
Page2 with 6 elements in the CLV
Page3 with 7 element in the CLV

B4X:
Sub clvMenu_ItemClick (Index As Int, Value As Object)
    #If debug
    Log("CLV Index: " & Index)
    Log("CLV Value: " & Value)
    #end IF
   
End Sub

If i click on the Page1 i get CLV Index from 0 to 7
If i click on the Page2 i get CLV Index from 0 to 5
If i click on the PAge3 i get CLV Index from 0 to 6


B4X:
Sub btnMas_Click

    'Get the index of the sender
    Dim index1 As Int
    Dim btn As Button = Sender
    index1 = btn.Tag
    Log("Index Boton: " & index1)

    Dim index As Int = clvMenu.GetItemFromView(Sender)
    Log("Index CLV: " & index)
   
    Dim pnl As Panel
    pnl = clvMenu.GetPanel(index)
   

End Sub

So if i try to get the text of the label when i click on the button on the Page3 all works right but when i try to get this from the Page1 or Page2 i get the error "Object was not initialized (UIView)"

Could somebody tell me what's wrong how can i get this work.

Thanks in advance.
 

salvadoro

Member
Licensed User
Longtime User
Yes Erel,
Here is a sample with the problem is a mix with clv and itabstrip, with the Page3 works but with Page1 or Page2 there is the problem, i get the error "Object was not initialized (UIView)".

Thanks for your help.
 

Attachments

  • CustomListView.zip
    70.2 KB · Views: 193
Upvote 0
Top