Android Question xCustomListView problem

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
i started to use B4A 9.01 and i opened my old projects with it,
and i unchecked CustomListView from the lib and checked the xCustomListView
every thing was alright except my (clv.add) and (clv2.insertat)
and gives the following error
main_add1tolist (java line: 1068)
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.res.ColorStateList.getDefaultColor()' on a null object reference
at anywheresoftware.b4a.objects.B4XViewWrapper.getColor(
at b4a.example3.customlistview._insertatimpl(
at b4a.example3.customlistview._insertat(
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(
at anywheresoftware.b4a.keywords.Common$
at android.os.Handler.handleCallback(Unknown Source:2)
at android.os.Handler.dispatchMessage(Unknown Source:4)
at android.os.Looper.loop(Unknown Source:155)
at Source:65)
at java.lang.reflect.Method.invoke(Native Method)
at$ Source:11)
at Source:345)
and the line of code witch rise that error is
clv2.InsertAt(0,CreateListItem("dd",clv2.AsView.Width, 60dip), $"Item !!!"$)
''''''''''''''''''''''' creat panel function''''''''''''''''''''''''''
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.SetLayout(0, 0, Width, Height)
    Label1.Text = Text
    Return p
End Sub

i'd like to note that i downloaded b4a example of (xCustomListView) it works fine
and also im did not add the module (CustomListView.bas) to the project

i hope to find answer after tow days searching in similar problems in B4A forum?
Last edited:


Active Member
Licensed User
Longtime User
If you have switched your CustomListView then if you have a Layout file with a CustomListView then you will need to delete the CustomListView, save it, and then add it back from the CustomViews list.

Hope this makes sense
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
i deleted the (clv) from layout and i recreated new one with same name and saved the project and reopened it again but error still as it is
Upvote 0

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
thank Mr Erel
i solved the problem by deleteing the layout its self (not just deleting the CLV from it) and i recreate the layout in B4X 9 and the CLV after that every thing work fine
thanks a lot for you Mr Erel again.
Upvote 0