Android Question IllegalStateException

Declan

Well-Known Member
Licensed User
Longtime User
I get the following error:
B4X:
Error occurred on line: 546 (HomePage)
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
    at android.view.ViewGroup.addViewInner(ViewGroup.java:4066)
    at android.view.ViewGroup.addView(ViewGroup.java:3916)
    at android.view.ViewGroup.addView(ViewGroup.java:3888)
    at anywheresoftware.b4a.objects.PanelWrapper.AddView(PanelWrapper.java:65)
    at com.rob.ebuki.homepage._loadhomeworklist(homepage.java:1783)
    at com.rob.ebuki.homepage._imghw_click(homepage.java:1682)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:78)
    at android.view.View.performClick(View.java:4848)
    at android.view.View$PerformClick.run(View.java:20262)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5631)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
** Service (starter) Destroy **
** Activity (homepage) Pause, UserClosed = true **

The line of code that creates the error:
B4X:
    pnlHWlist.AddView(lvHomework, 0, 0, pnlHWlist.width, pnlHWlist.height)
 

udg

Expert
Licensed User
Longtime User
Hi,
if I'm not wrong, that means that lvHomework is a child of a different item, so it dictates to remove it from its parent before adding it to pnlHWlist.
 
Upvote 0
Top