Android Question Output in ScrollView very slow


Active Member
Licensed User
I currently want Output 413 data records in a scroll view. The number of records is steadily increasing. Approx. 12 seconds are required for the output. Is there a way to speed up the output or to program another type of output with a similar appearance?
The planned sample program with data is unfortunately too large, so only extracts from the programming. The code is repeated 413 times in a loop.


Sub Ausgaben_aus_DB_lesen
    Dim T1 As String
    DateTime.TimeFormat = "HH:mm:ss"

    T1 = DateTime.TimeParse(DateTime.Time(DateTime.Now))

    Cursor97 = Starter.SQL_DB.ExecQuery("SELECT Ident_Nr, Finanzverlauf_Name, Konto, Summe_Finanzverlauf, Datum, Datum_zum_sortieren, Kategorie, Beschreibung, Text_Waehrung_Abkuerzung, Speicherpfad_Icon FROM Finanzverlauf")' order by Datum_zum_sortieren, Ident_Nr DESC")

    ScrollView_Finanzverlauf.Panel.Width = 780dip
    ScrollView_Finanzverlauf.Panel.Height = 82dip+((Cursor97.RowCount-1)*56dip)' +10dip

    If ScrollView_Finanzverlauf.Panel.Height < 1000dip Then
        ScrollView_Finanzverlauf.Panel.Height = 1000dip
    End If
    For i=1 To Cursor97.RowCount
        Cursor97.Position = i-1

        'IconButton für Kont0 erzeugen
        Dim Button_Konto_Icon As BitmapDrawable
        Button_Konto_Icon.Initialize(LoadBitmap(File.DirAssets, "Muenzen_45x30.png"))
        KontoIcon.IconPadding = 0    '350   'geändert
        Dim c As ColorDrawable
        KontoIcon.Background = c
        ScrollView_Finanzverlauf.Panel.AddView(KontoIcon, 15dip, 8dip+(Cursor97.Position*56dip), 80dip, 50dip)

        'Textzeilen der Ausgaben ohne Geldbetrag
        Dim c As ColorDrawable
        Verschiedene_Ausgaben_Zeile1.Background = c
        Verschiedene_Ausgaben_Zeile1.Text = Cursor97.GetString("Finanzverlauf_Name")
        Verschiedene_Ausgaben_Zeile1.Tag = i
        Verschiedene_Ausgaben_Zeile1.TextColor = Colors.Black
        Verschiedene_Ausgaben_Zeile1.Typeface = Typeface.DEFAULT
        Verschiedene_Ausgaben_Zeile1.Gravity = Bit.Or(Gravity.LEFT, Gravity.BOTTOM)
        Verschiedene_Ausgaben_Zeile1.TextSize =16
        ScrollView_Finanzverlauf.Panel.AddView(Verschiedene_Ausgaben_Zeile1, 100dip, 5dip+(Cursor97.Position*56dip), 660dip, 40dip)
        'Textzeilen  Ausgabekategorien
        Dim c As ColorDrawable
        Verschiedene_Ausgabekategorien_Zeile2.Background = c
        Verschiedene_Ausgabekategorien_Zeile2.Text = Cursor97.GetString("Kategorie")
        Verschiedene_Ausgabekategorien_Zeile2.Tag = i
        Verschiedene_Ausgabekategorien_Zeile2.TextColor = Colors.Red    '.ARGB(255,31,122,31)    '(255,26,101,26)    '(255,21,81,21)
        Verschiedene_Ausgabekategorien_Zeile2.Typeface = Typeface.DEFAULT
        Verschiedene_Ausgabekategorien_Zeile2.Gravity = Bit.Or(Gravity.LEFT, Gravity.BOTTOM)
        Verschiedene_Ausgabekategorien_Zeile2.TextSize =16
        ScrollView_Finanzverlauf.Panel.AddView(Verschiedene_Ausgabekategorien_Zeile2, 100dip, 30dip+(Cursor97.Position*56dip), 660dip, 38dip)
        '        'Textzeile der Verschiedene_Ausgaben_Werte nur Geldbetrag Zeile1
        Dim c As ColorDrawable
        Verschiedene_Ausgaben_Werte.Background = c
        Verschiedene_Ausgaben_Werte.Text = "-" & NumberFormat2(Cursor97.GetDouble("Summe_Finanzverlauf"), 1, 2, 2, False) & " " & Cursor97.GetString("Text_Waehrung_Abkuerzung")
        Verschiedene_Ausgaben_Werte.Tag = i
        Verschiedene_Ausgaben_Werte.Color = Colors.Transparent
        Verschiedene_Ausgaben_Werte.TextColor = Colors.Red    '.ARGB(255,31,122,31)
        Verschiedene_Ausgaben_Werte.Typeface = Typeface.DEFAULT_BOLD
        Verschiedene_Ausgaben_Werte.Gravity = Bit.Or(Gravity.RIGHT, Gravity.BOTTOM)
        Verschiedene_Ausgaben_Werte.TextSize =16
        ScrollView_Finanzverlauf.Panel.AddView(Verschiedene_Ausgaben_Werte, 100dip, 5dip+(Cursor97.Position*56dip), 660dip, 40dip)
        'Textzeile der Verschiedene_Ausgaben_Datum nur Datum Zeile2
        Verschiedene_Ausgaben_Datum.Background = c
        Verschiedene_Ausgaben_Datum.Text = Cursor97.GetString("Datum")
        Verschiedene_Ausgaben_Datum.Tag = i
        Verschiedene_Ausgaben_Datum.Color = Colors.Transparent
        Verschiedene_Ausgaben_Datum.TextColor = Colors.Black
        Verschiedene_Ausgaben_Datum.Typeface = Typeface.DEFAULT
        Verschiedene_Ausgaben_Datum.Gravity = Bit.Or(Gravity.RIGHT, Gravity.BOTTOM)
        Verschiedene_Ausgaben_Datum.TextSize =16
        ScrollView_Finanzverlauf.Panel.AddView(Verschiedene_Ausgaben_Datum, 100dip, 30dip+(Cursor97.Position*56dip), 660dip, 38dip)
        'Transparentes Label ohne Text, nur für anklicken und somit starten der Transaktion
        Transparenter_Button.Background = c
        Transparenter_Button.Text = ""
        Transparenter_Button.Tag = i
        Transparenter_Button.Color = Colors.Transparent
        Transparenter_Button.TextColor = Colors.Black
        Transparenter_Button.Typeface = Typeface.DEFAULT
        Transparenter_Button.Gravity = Bit.Or(Gravity.RIGHT, Gravity.BOTTOM)
        Transparenter_Button.TextSize =12
        ScrollView_Finanzverlauf.Panel.AddView(Transparenter_Button, 3dip, 7dip+(Cursor97.Position*56dip), 760dip, 56dip)
        Canvas1.DrawLine(20dip, 54dip, 750dip, 54dip, Colors.Black, 2dip)



Peter Simpson

Licensed User
Could you explain where the problen(s) was/were.

Hello @klaus,
He sent me his database, but later sent me some code that was running but not exactly efficiently.

The code had multiple issues, probably due to the fact that there is no straight working example of lazy loading (following Erels example means implementing it in two parts), something that I am aiming to remedy in the next few days. His code also included #AdditionalJar: sqlite-jdbc-3.21.0 which wasn't needed, added the customlistview class instead of using the library and quite a few other issues, but it's all a learning process for him.

I personally believe that the main issues is that if one doesn't know this forum very well, it is relatively easy to get lost while trying to find the newest recommended solutions to accomplish a given task in an application. A developer can end up using older more complicated bits of code from the forum when a newer solution could be just a couple of posts away.
Upvote 0


Licensed User
Yes, I agree with you :)!
Even if you follow the forum on a regular base it's not that easy to find always the best or latest solution.
Then, the question is, how could it be improved? I don't know, it's a quite difficult task.
Upvote 0


Well-Known Member
Licensed User
Then, the question is, how could it be improved? I don't know, it's a quite difficult task.
The simple solution, IMHO, I have made a request to all.


Upvote 0


Active Member
Licensed User
I would like to thank everyone again for their help, especially @Peter Simpson for his active help with this sample program. Regarding my self-made program, I would just like to mention that e.g. B. #AdditionalJar: sqlite-jdbc-3.21.0 from an old application was still included and some libraries were selected too many. Just didn't remove this as it had no effect on the program and I wanted to get a result quickly. Realize that this has caused confusion and will improve. Of course, the program I created was not nearly as efficient as that of @Peter Simpson, but I think I have learned something again. As a hobby programmer who has taught himself everything, there are some problems with understanding. Nevertheless, I am delighted and grateful to always have the help of experts who also address the problems of less experienced amateur programmers.
For beginners like me, you're the salt in a soup in a forum.
Have a nice weekend
Upvote 0