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?
this is the code, button1 works but the B4XSwitch does not (BtnSchedEnable) is there a way to get the index with GetItemFromView on a B4XSwitch? or any other means? Regards, Mike Sub BtnSchedEnable_ValueChanged (Value As Boolean) Try Dim MyIndex As Int...
www.b4x.com
Edit: Disregard. The custom view base panel is now Public ... see below.
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.
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).
Sorry for the confusion. The tag is relevant in the case where you want to get the class instance from the view. In this case, you should do exactly as you did.