B4J Question How to use xCustomListView as a Simple ListView

Giu

Member
Licensed User
Longtime User
Hi,

I'm feeling st###d asking, but seriously, I don't have clear reading in the forums how to use xCustomListView.

For a commandline in B4J application I'm working, I thought to "migrate" to an UI version, I created a new project and moved the code. Previously I was using Log to write to output to show progress about what application is doing, and now, I'm trying to use the usual listview. I readed to use xCustomListView, but I can't understand how it works at all. I think the 2 main methods are Add and AddTextItem. I guess Add() is for more complex listviews, I just need to show line of texts one after another, and I think AddTextItem is the way to go, but I can't make it work, not sure what it expects as parameters at all. I tried as I saw in others thread just something like

I added library xCustomListView, added CustomListView from designer, and generate member in my code with "Private clv As CustomListView"

B4X:
Dim separator As String = "********"
    
lv.AddTextItem(separator, separator)

But I end up with an NullPointer Exception

B4X:
Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Error occurred on line: 23 (Main)
java.lang.NullPointerException
    at b4j.example.customlistview._addtextitem(customlistview.java:82)
    at b4j.example.main._appstart(main.java:97)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.start(main.java:38)
    at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
    at java.base/java.lang.Thread.run(Thread.java:834)

How can I read more about exactly how to use this xCustomListView?
 

monki

Active Member
Licensed User
Longtime User
Hallo,
you define the xCustomListView > Private clv As CustomListView",
In your Code use lv.AddTextItem(separator, separator)
 
Upvote 0
Top