Hi,
I need to speed up my CustomListView.
This is the code of the ListView:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
This is the part of CreateItem:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
This part seems to take some time:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Main:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
This is slow from 10 lines and more.
Is there a way to speed this up? Can I optimize my code?
Kind regards,
André
			
			I need to speed up my CustomListView.
This is the code of the ListView:
			
				B4X:
			
		
		
		Sub OpdrachtOverzicht(row As Int)
    Log(1&"-"&DateTime.Time(DateTime.Now))
    OpdrachtIDList.Clear
    OpdrachtTable.Clear
    OpdrachtTable.AsView.Visible=True
   
    Main.SQL1.BeginTransaction
    Dim Query As String = "SELECT ROWID, Ingetrokken, Berichtnummer, Naam, Begintijd, Opdracht, Bewaart, Toelichting FROM "&Main.DBOpdrachten&" WHERE Begindatum='"&DisplayDatum&"' AND Eindeuitvoering='' ORDER BY Begintijd"
    Dim res As ResultSet = Main.SQL1.ExecQuery(Query)
   
    DBUtils.EmptyTable(Main.SQL1,"DumpTabel")
    Do While res.NextRow
        If(res.Getstring("Ingetrokken")="1" And Starter.IngetrokkenZichtbaar=False) Then
        Else
            EigenFuncties.Aanvulling(res.GetInt("Berichtnummer"))
        End If
    Loop
    If(lstToelichting.IsInitialized=False) Then lstToelichting.Initialize
    lstToelichting.Clear
    res.Position=-1
    Do While res.NextRow
        If(res.Getstring("Ingetrokken")="1" And Starter.IngetrokkenZichtbaar=False) Then
        Else
            If(res.Position=3) Then
                ProgressDialogShow("Laden")
                Sleep(0)
            End If
            OpdrachtIDList.Add(res.GetInt("ROWID"))
            Dim p As B4XView = CreateItem(res.GetInt("Berichtnummer"),res.GetString("Ingetrokken"), res.GetString("Naam"),res.GetString("Begintijd"),res.GetString("Opdracht"),res.GetString("Bewaart"),res.GetString("Toelichting"))
            OpdrachtTable.Add(p, expandable.CreateValue(p, "some value"))
            If(res.Getstring("Ingetrokken")<>"1") Then expandable.ToggleItem(OpdrachtTable.Size-1)
            lstToelichting.Add(res.GetString("Toelichting"))
        End If
    Loop
    If(res.RowCount>0) Then
        OpdrachtTable.JumpToItem(row)
        ProgressDialogHide
    End If
    res.Close
    Main.SQL1.EndTransaction
    Log(2&"-"&DateTime.Time(DateTime.Now))
End Sub
	This is the part of CreateItem:
			
				B4X:
			
		
		
		Sub CreateItem(Bericht As Int, Ingetrokken As Int, Klantnaam As String, Tijd As String, Omschrijving As String, Reeds As String, Toelichting As String) As B4XView
    Dim p As B4XView = xui.CreatePanel("")
    'EigenFuncties.Aanvulling(Bericht)
    Dim Rows As Int=Main.SQL1.ExecQuerySingleResult("SELECT COUNT(*) FROM Dumptabel WHERE Berichtnummer="&Bericht)
    p.SetLayoutAnimated(0, 0, 0, OpdrachtTable.AsView.Width, tblAanvulling1.RowHeight*Rows+tblAanvulling1.HeaderHeight+HeaderHoogte+NaamHoogte)
    p.Height=tblAanvulling1.RowHeight*Rows+tblAanvulling1.HeaderHeight+HeaderHoogte+NaamHoogte
    p.Width=OpdrachtTable.AsView.Width
    p.LoadLayout("Item")
    p.SetLayoutAnimated(0, 0, 0, p.Width, p.GetView(0).Height) 'resize it to the collapsed height
    'Log("1A"&"-"&DateTime.Time(DateTime.Now))
    HeaderHoogte=p.GetView(0).Height
    NaamHoogte=lblKlantNaam.Height
   
    lblKlantNaam.Text=Klantnaam
    lblTijd1.Text=Tijd
    lblOmschrijving1.Text=Omschrijving
    If(Toelichting<>"" And Toelichting<>Null) Then
        btnSpeak.Visible=True
    Else
        btnSpeak.Visible=False
    End If
    If(Reeds=1) Then
        lblReeds1.Visible=True
    Else
        lblReeds1.Visible=False
    End If
    If(OpdrachtTable.Size Mod 2 = 0) Then
        pnlTitle.Color = Colors.White
    Else
        pnlTitle.Color = EigenFuncties.HexToColor("#FFF0FFFF")
    End If
    pnlExpanded.Color = ShadeColor(Colors.White)
    'Log("1B"&"-"&DateTime.Time(DateTime.Now))
    If (Ingetrokken=1 )Then
        Dim rs As RichString
        rs.Initialize(lblOmschrijving1.Text)
        rs.Strikethrough(0,rs.Length)
        lblOmschrijving1.Text=rs
        lblOmschrijving1.TextColor=Colors.Red
        rs.Initialize(lblTijd1.Text)
        rs.Strikethrough(0,rs.Length)
        lblTijd1.Text=rs
        lblTijd1.TextColor=Colors.Red
       
        rs.Initialize(lblReeds1.Text)
        rs.Strikethrough(0,rs.Length)
        lblReeds1.Text=rs
        lblReeds1.TextColor=Colors.Red
    End If
    If(Bericht<>0) Then
        'Log("1C"&"-"&DateTime.Time(DateTime.Now))
        tblAanvulling1.Height=tblAanvulling1.RowHeight*Rows+tblAanvulling1.HeaderHeight
        tblAanvulling1.ClearAll
        tblAanvulling1.LoadSQLiteDB(Main.SQL1,"SELECT Actie, Omschrijving, Aantal FROM DumpTabel WHERE Berichtnummer="&Bericht,False)
        tblAanvulling1.SetColumnsWidths(Array As Int(90dip,tblAanvulling1.Width-145dip,55dip))
        tblAanvulling1.SetCellAlignments(Array As Int(Gravity.LEFT,Gravity.LEFT,Gravity.CENTER))
        tblAanvulling1.SetHeaderAlignments(Array As Int(Gravity.LEFT,Gravity.LEFT,Gravity.CENTER))
    End If
    'Log("1D"&"-"&DateTime.Time(DateTime.Now))
    EigenFuncties.ResetUserFontScale(p)
    'Log("1E"&"-"&DateTime.Time(DateTime.Now))
   
    Return p
End Sub
	This part seems to take some time:
			
				B4X:
			
		
		
		tblAanvulling1.LoadSQLiteDB(Main.SQL1,"SELECT Actie, Omschrijving, Aantal FROM DumpTabel WHERE Berichtnummer="&Bericht,False)
	Main:
			
				B4X:
			
		
		
		Dim SQL1 As SQLCipher
	This is slow from 10 lines and more.
Is there a way to speed this up? Can I optimize my code?
Kind regards,
André