Android Question Keep a Custom List View Item selected

Mattiaf

Active Member
Licensed User
Hi, I have a custom list view and every time I click an item a panel is showing right on top of it. But it would be great to keep the item selected so the user can keep the view on which item he selected. I ve been looking around but it doesn't seem there is a way to keep the item selected, at least, until the panel is displaying right above.. Thanks
 
Solution
This is what you are looking for. You can keep single item selected or multiple items

mcqueccu

Well-Known Member
Licensed User
Longtime User
This is what you are looking for. You can keep single item selected or multiple items

 
Upvote 2
Solution

Mattiaf

Active Member
Licensed User
Thanks.
I added the .bas file as existing module,
on class global
B4X:
Dim selezionepermanente As CLVSelections

on initialize
B4X:
selezionepermanente.Initialize(clvChiavi)
    selezionepermanente.Mode = selezionepermanente.MODE_SINGLE_ITEM_PERMANENT

on the cls item click event
B4X:
selezionepermanente.ItemClicked(Index)

but as soon as I debug, it shows the following error message

B4X:
Logger connected to:  samsung SM-G985F
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 35 (CLVSelections)
java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.objects.collections.List.getSize()' on a null object reference
    at b4a.example3.customlistview._getsize(customlistview.java:493)
    at Chiavii.ronda.clvselections._refresh(clvselections.java:251)
    at Chiavii.ronda.clvselections._setmode(clvselections.java:188)
    at Chiavii.ronda.b4xmainpage._initialize(b4xmainpage.java:917)
    at Chiavii.ronda.b4xpagesmanager._initialize(b4xpagesmanager.java:153)
    at Chiavii.ronda.main._activity_create(main.java:420)
    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:146)
    at Chiavii.ronda.main.afterFirstLayout(main.java:105)
    at Chiavii.ronda.main.access$000(main.java:17)
    at Chiavii.ronda.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8741)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
** Activity (main) Resume **

the line 35 in the class is
B4X:
Public Sub Refresh
    VisibleRangeChanged(0, mCLV.Size - 1)
End Sub

what is the issue? thanks
 
Upvote 0

Mattiaf

Active Member
Licensed User
hmm to be honest I don't see any error between how I implement it and how the b4j example is built... Am I wrong?
 
Upvote 0

Mattiaf

Active Member
Licensed User
OK got it..
Just need it on the b4x page created
B4X:
selezionepermanente.Initialize(clvChiavi)
    selezionepermanente.Mode = selezionepermanente.MODE_SINGLE_ITEM_PERMANENT
 
Upvote 0

Mattiaf

Active Member
Licensed User
@mcqueccu just a thing..
How can I parse it as a boolean?
I mean how can i do something like this
if item is clicked then
panel.visible=true
else
item clicked.clear
?
 
Upvote 0
Top