Android Question Help with troubleshooting in CustomListView

strupp01

Active Member
Licensed User
Longtime User
I created a program that runs on one tablet with Android 14 and another tablet with Android 16.

There are no problems with Android 14. With Android 16, the following error message appears:


1770897847806.png



I can't make sense of this error message. There's also no line number indicating where the program crashes.

However, I now know which subroutine causes the program to crash.

B4X:
Sub CustomListView_Einzelner_Bericht_Ausgaben_Kategorien_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    If (CustomListView_Einzelner_Bericht_Ausgaben_Kategorien.Size - 1) > 0 Then
        Dim ExtraSize As Int = 15 'List size
        For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, CustomListView_Einzelner_Bericht_Ausgaben_Kategorien.Size - 1)
            Dim Pnl As B4XView = CustomListView_Einzelner_Bericht_Ausgaben_Kategorien.GetPanel(i)
            If Pnl.NumberOfViews = 0 Then
                Log(i)
'                If i > 0 Then
                If i > 0 Then    'Anzahl_Kategorien_mit_Geld - 1 Then    'List_Kategorien_Geld.size - 1 Then
                    Canvas1.Initialize(Panel_einzelne_Aktion)
                    Canvas1.DrawLine(0dip, 73dip, 740dip, 73dip, Colors.Black, 5dip)

                    Pnl.LoadLayout("cellItem")
                    Dim DD As DatanInfoAusgabenKategorie = CustomListView_Einzelner_Bericht_Ausgaben_Kategorien.GetValue(i)
                   
                    Label_Kategorie.TextColor = Colors.ARGB(255,31,122,31)
                    Label_Geldbetrag.TextColor = Colors.ARGB(255,31,122,31)
                   
                    LabelKontoaktion.Text = DD.Ausgaben_Name
                    Label_Kategorie.Text = DD.Kategorie
                    Label_Datum.Text = DD.Datum
                    Label_Geldbetrag.Text = $"${NumberFormat2(DD.Summe_Ausgaben, 1, 2, 2, False)} ${DD.Text_Waehrung_Abkuerzung}"$
                    ImageView_Icon.SetBitmap(xui.LoadBitmapResize(File.DirAssets, DD.Speicherpfad_Icon, ImageView_Icon.Width, ImageView_Icon.Height, True))
                Else
                    Pnl.LoadLayout("cellItem_Bericht_Ausgaben_Kategorie")
                    Dim DD As DatanInfoAusgabenKategorie = CustomListView_Einzelner_Bericht_Ausgaben_Kategorien.GetValue(i)
                   
                    Label_Kategorie.TextColor = Colors.Black        '.ARGB(255,31,122,31)
                    Label_Geldbetrag.TextColor = Colors.ARGB(255,31,122,31)
                   
                    Label_Kategorie.Text = DD.Kategorie
                    B4XProgressBar_Prozente.Progress = DD.Balkenlaenge
                   
                    'Prozentzahl hinter Balken eintragen
                    Label_Prozent.Initialize("Label_Prozent")
                    Label_Prozent.TextColor = Colors.Black
                    Label_Prozent.Gravity = Gravity.LEFT
                    Label_Prozent.Typeface = Typeface.DEFAULT_BOLD
                    Label_Prozent.TextSize = 24
                    Label_Prozent.Text = NumberFormat2(DD.Prozentanteil_Wert, 1, 2, 2, False) & " %"
                   
                    Dim Temp As Int
                    Temp = (300 / 100 * DD.Balkenlaenge) * 2.5
                    Pnl.AddView(Label_Prozent, Temp + 30dip, 32dip, 110dip, 30dip)'((400)/Ausgangswert * DD.Prozentanteil_Wert), 32dip, 100dip, 30dip)
                   
                    Label_Geldbetrag.Text = $"${NumberFormat2(DD.Summe_Ges_Kategorie, 1, 2, 2, False)} ${DD.Text_Waehrung_Abkuerzung}"$
                End If
'                End If
            End If
        Next
    End If
End Sub

I'm using the same subroutine, but with income instead of expenses, and there are no problems.

If I set a breakpoint in the loop I so that it always pauses at that point, the program also runs without any issues.

I can't upload the program because it's too large and the data is personal.

Perhaps someone has an idea where the problem lies and can help me.

Thank you in advance.

Regards, strupp01
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Better to copy logs as text (right click) and post instead of screenshot.

Try to use lazy loading to load the items, refer to this
This is indeed the solution. The error happens where there are many views and the OS saves the Activity state when the activity is paused.
 
Upvote 0

strupp01

Active Member
Licensed User
Longtime User
I've double-checked everything. I'm loading the data in 747ms. Despite this, the program keeps crashing with an error message. If I stop the program after loading or at the beginning of the output using a breakpoint, it runs without any problems. I can't find a solution.
 
Upvote 0
Top