Android Question Error while using customlistview

Makumbi

Well-Known Member
Licensed User
here is my code

B4X:
Sub Pastrecords_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    Dim ExtraSize As Int = 25 'List size
    For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, pastrecords.Size - 1)
        Dim Pnl As B4XView = pastrecords.GetPanel(i)
        If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
            If Pnl.NumberOfViews = 0 Then 'Add each item/layout to the list/main layout
                Dim AD As StudentDatacompare = pastrecords.GetValue(i)
                Pnl.LoadLayout("Displaycompare")
                Names.Text = AD.Names
                Subject.Text = AD.Subject
                First.Text= AD.First
                Second.Text = AD.Second
                Secagg.Text = AD.Secagg
                Firsagg.Text= AD.Firsagg
                Differenceagg.Text=AD.Differenceagg
                Differencemks.Text=AD.Differencemks
        
            End If
        Else 'Not visible
            If Pnl.NumberOfViews > 0 Then
                Pnl.RemoveAllViews 'Remove none visable item/layouts from the list/main layout
            End If
        End If
    Next
End Sub

Sub TxtSearchFilter_TextChanged (Old As String, New As String)

'
'pastrecords.Clear
    Sleep(0)

    'Dim SenderFilter As Object
    
    Log(Account.Text)

Dim rs As ResultSet = Starter.SQL1.ExecQuery2("SELECT DISTINCT Names,Subject,First,Second,Firsagg,Secagg,Differencemks,Differenceagg,Categorymks,Categoryagg FROM AcademicsLoadCompare WHERE admno = ?", Array As String(Account.Text))



'    Wait For (SenderFilter) SQL_QueryComplete (Success As Boolean, rs As ResultSet)
'    If Success Then
        'Dim StartTime As Long = DateTime.Now
        Do While rs.NextRow
            Dim AD As StudentDatacompare
            AD.Initialize
            AD.Names    = rs.GetString("Names")
            AD.Subject = rs.GetString("Subject")
            AD.First    = rs.GetString("First")
            AD.Second = rs.GetString("Second")
            'AD.Subject= rs.GetString("Class")
            AD.Firsagg= rs.GetString("Firsagg")
            AD.Secagg= rs.GetString("Secagg")
            AD.Differencemks= rs.GetString("Differencemks")
            AD.Differenceagg= rs.GetString("Differenceagg")
            AD.categorymks= rs.GetString("Categorymks")
            AD.categoryagg= rs.GetString("Categoryagg")
            'AD.Sst= rs.GetString("sstscore")
            'AD.Science= rs.GetString("sciencescore")
            'AD.Division= rs.GetString("Division")
                    
            Dim Pnl As B4XView = xui.CreatePanel("")
            Pnl.SetLayoutAnimated(0, 0, 0, pastrecords.AsView.Width, 130dip) 'Panel height + 4 for drop shadow
            pastrecords.Add(Pnl, AD)
        Loop
        rs.Close
        
        
    'Else
    '    Log(LastException)
    'End If
    
End Sub



iam getting the following two errors please help
first error occours here

B4X:
'
pastrecords.Clear
    Sleep(0)
after terminating another error comes here
B4X:
    Dim Pnl As B4XView = xui.CreatePanel("")
            Pnl.SetLayoutAnimated(0, 0, 0, pastrecords.AsView.Width, 130dip) 'Panel height + 4 for drop shadow
            pastrecords.Add(Pnl, AD)
        Loop
        rs.Close

B4X:
Categorymks: DECLINED
CategoryAgg: null
admno: 19-07561
First: null
Names: MAKUMBI TARIQ AZIZI
Subject: RE
Second: null
Firsagg: null
Secagg: null
DifferenceMks: null
DifferenceAgg: null
Categorymks: null
CategoryAgg: null
Error occurred on line: 433 (Compareresults)
java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.collections.List.Clear()' on a null object reference
    at b4a.example3.customlistview._clear(customlistview.java:200)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at com.kccug.kabojjajuniorapp.compareresults._txtsearchfilter_textchanged(compareresults.java:1522)


second error

B4X:
Second: null
Firsagg: null
Secagg: null
DifferenceMks: null
DifferenceAgg: null
Categorymks: null
CategoryAgg: null
19-07561
Error occurred on line: 466 (Compareresults)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:725)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1705)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
 
Top