Android Question Field customlistview was declared with the wrong type

endive

New Member
Hi there

I am new to B4X, and trying to develop a mobile app with B4A, which so far I found excellent compared to previous language I was using. Currently I am stuck with the CustomListView control. I want a CustomListView display a list of images with some added legends for each image. I followed Erel's video tutorial as adapted to my app. There is the main layout (B4XMainPage) with a panel in which there is the clv control, and I created another layout for the list, as shown in the tutorial, loaded at runtime and used by the clv control. The debugger keeps crashing with the same error (full log copied below).

I saw other posts on this forum on the same topic but did not find a way to get rid of this crash:
- the xCustomListView library files are in the libraries folder of B4A
- the CustomListView control on my layout was added from the CustomView submenu in the designer (in that menu there is "CustomListView", not "xCustomListView", but I understand this is normal)
- the list of libraries used by my project is the following:
1751959053031.png


the added customlistview control is declared in the sub Class_Globals like other controls (list of controls shortened for the post):

B4X:
Sub Class_Globals
        
    Private Root As B4XView
    Private xui As XUI
    Private Button1 As Button
    Private Button2 As Button
    Private ImageView1 As ImageView
    Private B4XTable1 As B4XTable
    Private B4XComboBox1 As B4XComboBox
    Private B4XFloatTextField1 As B4XFloatTextField
    Private Label10 As Label
    Private Label11 As Label
    Private ImageView5 As ImageView
    Private CustomListView1 As CustomListView
    Type itemvalue(text1 As Label, text2 As Label, text3 As Label)
    
End Sub

Any help to fix this issue would be welcome!

Thx

Pierre

The crash logs are the following:

Logger connecté à : HUAWEI ELE-L29
--------- beginning of main
--------- beginning of system
Copying updated assets files (3)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 146 (B4XMainPage)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1140)
at b4a.mynewapp1.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1074)
at b4a.mynewapp1.b4xpagesmanager._showpage(b4xpagesmanager.java:431)
at b4a.mynewapp1.b4xpagesmanager._addpage(b4xpagesmanager.java:251)
at b4a.mynewapp1.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:265)
at b4a.mynewapp1.b4xpagesmanager._initialize(b4xpagesmanager.java:171)
at b4a.mynewapp1.main._activity_create(main.java:437)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at b4a.mynewapp1.main.afterFirstLayout(main.java:105)
at b4a.mynewapp1.main.access$000(main.java:17)
at b4a.mynewapp1.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
... 24 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
... 25 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Field customlistview1 was declared with the wrong type.
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:155)
at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
at anywheresoftware.b4a.objects.B4XViewWrapper.LoadLayout(B4XViewWrapper.java:329)
at b4a.mynewapp1.b4xmainpage._b4xpage_created(b4xmainpage.java:181)
... 27 more
Caused by: java.lang.RuntimeException: Field customlistview1 was declared with the wrong type.
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:419)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:442)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:133)
... 30 more
** Activity (main) Resume **
 

endive

New Member
I attach the layout (renamed "mainpage2", but it's a copy paste of "MainPage" from my project, anonymized). This is obviously work in progress. The customlistview control is in panel 11 of the layout, brought to front when needed. The crash occurs in line 146 of my project when attempting to load this layout at app launch (line 3 below):

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    etc.
    
End Sub
Thx
Pierre
 

Attachments

  • mainpage2.bal
    42.9 KB · Views: 31
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. I see the problem. At some point you added CustomListView module instead of library. Remove the module if it is still there and then remove CustomListView view and add it again.

2. This is the not the best way to create layouts. The layout is בomplicated and you are missing features such as anchors. Better to split it into multiple layouts.
 
Upvote 0

endive

New Member
Thank you Erel, it works now. As to the layouts, indeed I need to create multiple ones instead of a pile of controls on a single one! I'll try reconfigure the app this way.
Cheers
Pierre
 
Upvote 0
Top