iOS Question Custom Cell - TableView help!!

QtechLab

Active Member
Licensed User
Longtime User
Goodmorning Everyone.

I need to implement in my app a Tableview with custom cell.
I've read the discussion "TableView with custom items" starded by Erel but i could not understand many things...

I need to a customCell with a Label and a Textfield, i created a panel with them through the Layouts Designer. They are placed in a Design called "CustomCell".

Every time i debug the code i'm obtaining only one row without the custom layout.
I need to add custom cell dinamically, dependings on TCP listener results.

Here's my code :
B4X:
Public Sub LoadPage(Caller As Page, impiantoSelezionato As Int, selezione As Int)

    chiamante = Caller
    impianto = impiantoSelezionato
    selez = selezione
  
    If Not(myPage.IsInitialized) Then
        myPage.Initialize("")
        myPage.RootPanel.LoadLayout("SetupItem")
    Else
        myPage.RootPanel.LoadLayout("SetupItem")
    End If
  
    Main.ActivePage = myPage
    Main.NavControl.ShowPage(myPage)
   
[INDENT]'theme color[/INDENT]
    Main.ColoreTema = 2

    table.Initialize("Table", False)
    myPage.RootPanel.AddView(table,0,0,100%x, 100%y)
    table.RowHeight = PnlCell.Height
  
    LoadData
  
End Sub

Private Sub LoadData
  
    proto.Initialize(Me)
    proto.Xpanel.WifiOn = False
    proto.ForceDdns = False
    proto.start
  
    If selez = 1 Then
      'request a type of data
    Else If selez = 2 Then
      'request another type of data
    End If
  
End Sub


Private Sub createCell(ID As Int, add As String) As Panel
    Dim p As Panel
    p.Initialize("")
    p.Width = PnlCell.Width
    p.Height = PnlCell.Height
    p.LoadLayout("CustomCell")
    Return p
End Sub


#Region "Letture da centrale"
'Response from TCP listener

Sub XpResponse_NomiGruppi(arg As LinkedList, CmdXp As XpCmd)
  
    Dim i As Int

[INDENT]'Arg.size is the number of custom cell that i've to create
'Arg.size depends on my server response.
'CmdXp isn't implemented yet
[/INDENT]
    For i=0 To arg.Size -1
        Dim tc As TableCell = table.AddSingleLine("")
        tc.ShowSelection = False
        tc.CustomView = createCell(i, arg.Get(i))
    Next
  
End Sub

#End Region


arg.size is always > 10

I need also to modify the Cells's textfields and labels values

Thnaks in advance for your answare
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…