Android Question xcustomlistview- error

kisoft

Well-Known Member
Licensed User
Longtime User
HI
I'm using xcustomlistview in this way.
B4X:
Sub Globals
    Private index As Int
    Private CustomListView1 As CustomListView
    Private button1 As Button
End Sub


Sub CreateListItem(Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    Activity.AddView(p, 0, 0, Width, Height)
    p.LoadLayout("cust2")
    p.RemoveView
    Return p
End Sub

Sub Button1_Click()
    index=CustomListView1.GetItemFromView(Sender)
    Log(index)
    modl
End Sub

Sub modl
    Select index
                Case 0
            wid.a=0
                        CallSub(widok,"wte")

            StartActivity(wid)
        Case 1
            StartActivity(dk)
        Case 2
                        Log(index)
        Case 3

when index = 2 I get this error:
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 93 (Main)
java.lang.ClassCastException: android.view.ViewRootImpl cannot be cast to android.view.View
    at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:69)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getParent(B4XViewWrapper.java:166)
    at b4a.example3.customlistview._getitemfromview(customlistview.java:408)
    at modlitewnik.gk2.main._button1_click(main.java:551)
    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.raiseEvent2(BA.java:180)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:6274)
    at android.view.View$PerformClick.run(View.java:24859)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6710)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)

Line 93 is the code:
B4X:
 index=CustomListView1.GetItemFromView(Sender)
Previously, everything worked well, the problem arose when I upgraded the SDK.
I am using B4A 9.0
 

kisoft

Well-Known Member
Licensed User
Longtime User
Error detected. A big brothel in the code ... that's the reason for this error.
 
Upvote 0
Top