iOS Question iTableView permanent selection

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi i'm learning how to use the tableview in the best way.
I'm trying to do a settings page like the ios one, with elements that opens other pages.


B4X:
Sub Process_Globals
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private Panel1 As Panel
    Private TableView1 As TableView
    Private TableView2 As TableView
    Private svg As SVG3x
End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    'Page1.RootPanel.LoadLayout("1")
    NavControl.ShowPage(Page1)
    TableView1.Initialize("tv", True)
    
    CreaImpostazioni
End Sub

Sub CreaImpostazioni
    TableView1.Initialize("tv", True)
    TableView1.AddSection("", "")
    
    Dim tc0 As TableCell = TableView1.AddSingleLine("Profilo")
    tc0.ShowSelection = False
    svg.Initialize(File.DirAssets, "icona_profilo.svg")
    tc0.Bitmap = svg.Export(28dip, 28dip)
    tc0.AccessoryType = tc0.ACCESSORY_INDICATOR

    TableView1.AddSection("", "")
    Dim tc As TableCell = TableView1.AddTwoLines("Luogo Stage", "Non ancora impostato")
    tc.ShowSelection = False

    svg.Initialize(File.DirAssets, "icona_luogo.svg")
    tc.Bitmap = svg.Export(28dip, 28dip)
    tc.AccessoryType = tc.ACCESSORY_INDICATOR
    
'    TableView1.AddSection("Conteggio delle ore", "Quando questa funzione è impostata su Automatico, l'app determinerà automaticamente quando sarai uscito dal luogo di lavoro. Ti conviene mettere su manuale se fai un lavoro intinerante")
'    Dim tc2 As TableCell = TableView1.AddSingleLine("Automatico")
'    tc2.AccessoryType = tc.ACCESSORY_CHECKMARK
'    TableView1.AddSingleLine("Manuale")

    TableView1.AddSection("","")
    Dim tc2 As TableCell = TableView1.AddSingleLine("Generali")
    tc2.ShowSelection = False

    svg.Initialize(File.DirAssets, "icona_generali.svg")
    tc2.Bitmap = svg.Export(28dip, 28dip)
    tc2.AccessoryType = tc.ACCESSORY_INDICATOR
    
    Dim tc3 As TableCell = TableView1.AddSingleLine("Notifiche")
    svg.Initialize(File.DirAssets, "icona_notifiche.svg")
    tc3.Bitmap = svg.Export(28dip, 28dip)
    tc3.AccessoryType = tc.ACCESSORY_INDICATOR
    
    Page1.RootPanel.AddView(TableView1, 0, 0, 100%x, 100%y)
End Sub

Sub Pagina
    TableView2.RowHeight = 100 'must set RowHeight before adding custom views.
    For i = 1 To 50
        Dim tc As TableCell = TableView2.AddSingleLine("")
        tc.ShowSelection = False
        tc.CustomView = CreateItem
    Next
End Sub

Private Sub CreateItem As Panel
    Dim p As Panel
    p.Initialize("")
    p.Width = 100%x
    p.Height = TableView2.RowHeight
    p.LoadLayout("1")
    Return p
End Sub

Sub tv_SelectedChanged (SectionIndex As Int, Cell As TableCell)
    If Cell.Text.ToString == "Generali" Then
        Dim p As Page
        p.Initialize("p")
        p.Title = "OK"
        p.RootPanel.Color = Colors.Yellow
        NavControl.ShowPage(p)
    End If
End Sub


This code create the tableview.

When i click an element it opens a yellow page, but when i go back the item is still selected (dark grey), how can i remove the selection when i go back (like in ios settings), maybe i'm using the tableview in a wrong way?

Thanks
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…