iOS Question iTableView issue

vincentehsu

Member
Licensed User
Longtime User
Hello Sir:

I wanna add the data to tableview via click New button

tS9uz

check the screen image here:

https://imgur.com/a/tS9uz


it's my code as below
B4X:
Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("Main")
    NavControl.NavigationBarVisible=False
    NavControl.ToolBarVisible=False
    NavControl.ShowPage(Page1)
    mylist.Initialize
    stepno=1
   
   
End Sub

Private Sub CreateItem(ShowText As String,FileName As String) As Panel
    Dim p As Panel
    p.Initialize("")
    p.Width = 100%x
    p.Height = tv.RowHeight
    p.LoadLayout("1")
    Label1.Text=ShowText
    ImageView1.Bitmap=LoadBitmap(File.DirAssets,FileName)
    ImageView1.Tag=ShowText
    Return p
End Sub

Sub New_Click
    Dim i As Int
    If mylist.Size=0 Then
        mylist.Add("B" & stepno)
    Else
        mylist.Add("B" & stepno)
    End If
    show
    tv.ReloadAll
    tv.SizeToFit
End Sub
Sub show()
    tv.Initialize("tv", False)
    Panel1.AddView(tv, 0, 0, 100%x, 100%y)
    tv.RowHeight = 50 'must set RowHeight before adding custom views.
    For i=0 To mylist.Size-1
        Dim tc As TableCell = tv.AddSingleLine("")
        tc.ShowSelection = False
        Dim a As Int=i+1
        tc.CustomView = CreateItem("B" & a,"safari.png")
        stepno=stepno+1
    Next
   
End Sub

but I don't know why there are just show one single data of first I inserted?
 

vincentehsu

Member
Licensed User
Longtime User
mylist is used be extended to another purpose,


but I do additems in to tv



B4X:
Sub show()
    tv.Initialize("tv", False)
    Panel1.AddView(tv, 0, 0, 100%x, 100%y)
    tv.RowHeight = 50 'must set RowHeight before adding custom views.
    For i=0 To mylist.Size-1
        Dim tc As TableCell = tv.AddSingleLine("")
        tc.ShowSelection = False
        Dim a As Int=i+1
        tc.CustomView = CreateItem("B" & a,"safari.png")
        stepno=stepno+1
    Next
  
End Sub

but I don't know why there are just show one single data of first I inserted?


btw,is there any sample project with xCustomListView?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0
Top