Hello I am trying to add more than one panel in a scrollview but the app crash and the error is :
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:4417)
at android.view.ViewGroup.addView(ViewGroup.java:4258)
at android.view.ViewGroup.addView(ViewGroup.java:4230)
at anywheresoftware.b4a.objects.PanelWrapper.AddView(PanelWrapper.java:65)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:753)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:343)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
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:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Anyone can help ???
the code is as below
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:4417)
at android.view.ViewGroup.addView(ViewGroup.java:4258)
at android.view.ViewGroup.addView(ViewGroup.java:4230)
at anywheresoftware.b4a.objects.PanelWrapper.AddView(PanelWrapper.java:65)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:753)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:343)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
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:5637)
at android.view.View$PerformClick.run(View.java:22429)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Anyone can help ???
the code is as below
B4X:
Dim scrvpanel As ScrollView
Dim Panel1 As Panel
Dim Panelo(10) As Panel
Dim a, top As Int
a = 0
top=0
Sub Activity_Create(FirstTime As Boolean)
scrvpanel.Initialize(100)
Panel1.Initialize("")
Activity.AddView(Panel1,10dip,179dip,70%x,230dip)
End Sub
Sub cmdGeneraStatistiche_Click
Panel1.AddView(scrvpanel,0,0,100%x,100%y)
For i=0 To miocursore.RowCount -1
Panelo(a).Initialize("Panel"&a)
miocursore.Position = i
lbl1.Text=miocursore.GetString("a")
lbl2.Text= miocursore.GetString("b")
lbl3.Text=miocursore.GetString("c")
lbl4.Text=spnFornitore.GetItem(miocursore.GetInt("d"))
lbl5.Text=miocursore.GetInt("e")
lbl6.Text=miocursore.GetDouble("f")
lbl7.Text=miocursore.GetDouble("g")
lbl8.Text=miocursore.GetDouble("h")
miopanelo
a = a +1
top = top + 91
Next
End Sub
Sub miopanelo
scrvpanel.Panel.AddView(Panelo(a),0,top,100%x,50%y)
Panelo(a).AddView(lbl1,0,0,120dip,10dip)
Panelo(a).AddView(lbl2,0,11dip,120dip,10dip)
Panelo(a).AddView(lbl3,0,21dip,120dip,10dip)
Panelo(a).AddView(lbl4,0,31dip,120dip,10dip)
Panelo(a).AddView(lbl5,125dip,0,120dip,10dip)
Panelo(a).AddView(lbl6,125dip,10dip,120dip,10dip)
Panelo(a).AddView(lbl7,125dip,21dip,120dip,10dip)
Panelo(a).AddView(lbl8,125dip,32dip,120dip,10dip)
scrvpanel.Panel.Height=scrvpanel.Panel.Height+190
End Sub