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(B4XViewWrapper.java:399)
at b4a.example3.customlistview._insertatimpl(customlistview.java:553)
at b4a.example3.customlistview._insertat(customlistview.java:535)
at cccb.com.main._add1tolist(main.java:1068)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1179)
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 android.app.ActivityThread.main(Unknown Source:65)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
at com.android.internal.os.ZygoteInit.main(Unknown Source:345)
and the line of code witch rise that error is
B4X:
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.Initialize("")
    p.SetLayout(0, 0, Width, Height)
    p.LoadLayout("cellitem2")
    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:

jimmyF

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
-j
 
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
Top