Android Question B4XSeekBar index in CustomListView

red30

Well-Known Member
Licensed User
Longtime User
If I try to get the index of the B4XSeekBar in CustomListView I get the error:
B4X:
Sub B4XSeekBar1_ValueChanged (Value As Int)
    Dim index As Int = allclv.GetItemFromView(Sender)
    Log(index)
End Sub
B4X:
Error occurred on line: 209 (Main)
java.lang.ClassCastException: b4a.example.b4xseekbar cannot be cast to android.view.View
    at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:88)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getParent(B4XViewWrapper.java:185)
    at b4a.example3.customlistview._getitemfromview(customlistview.java:413)
    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:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA$2.run(BA.java:387)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6865)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:504)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
How can I get the index of the B4XSeekBar in CustomListView?
 

mangojack

Expert
Licensed User
Longtime User

Edit: Disregard. The custom view base panel is now Public ... see below.
 
Last edited:
Upvote 0

mangojack

Expert
Licensed User
Longtime User
This will now work ...
B4X:
Sub B4XSeekBar1_ValueChanged (Value As Int)
    Dim sb As B4XSeekBar = Sender
    Dim index As Int = allclv.GetItemFromView(sb.mBase)
    Log(index)
End Sub
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Code by @mangojack in post 3 works well, but Erel in post 4 makes reference to a another thread. Does that mean it is a confirmation of mj's code or there is a different way of achieving the same result via the thread link of post 4. I tried it, but could not figure out a different way other than what mj showed.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
I had read that thread posted by @Erel earlier covering the use of .Tags .. but thought due to mBase being made Public (following updates)
it was now not necessary /superseded (to use the .tag method).
 
Upvote 0
Top