below is the error please help thanks find attached a small project where the error is coming from
this is where i select the spinner record
error occurs here
B4X:
sms: How will the work be marked?
Datesent: /Date(1588501226000)/
2
1588501225000
How will the work be marked?
IN
RVD
Error occurred on line: 262 (Getchats)
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:5034)
at android.view.ViewGroup.addView(ViewGroup.java:4865)
at android.view.ViewGroup.addView(ViewGroup.java:4837)
at anywheresoftware.b4a.objects.PanelWrapper.AddView(PanelWrapper.java:65)
at anywheresoftware.b4a.objects.B4XViewWrapper.AddView(B4XViewWrapper.java:305)
at b4a.example3.customlistview._insertatimpl(customlistview.java:567)
at b4a.example3.customlistview._insertat(customlistview.java:540)
at b4a.example3.customlistview._add(customlistview.java:71)
at b4a.example.getchats$ResumableSub_LoadMessages.resume(getchats.java:1177)
at b4a.example.getchats._loadmessages(getchats.java:1074)
at b4a.example.getchats._spnfirstname_itemclick(getchats.java:1335)
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:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
B4X:
Sub spnFirstName_ItemClick (Position As Int, Value As Object)
'Starter.oSQL.ExecQuerySingleResult2("UPDATE tbl_Messages SET INflag='READ' WHERE INflag LIKE '%UNREAD%' and ChatClientName = ?", Array As String(spnFirstName.SelectedItem))
clvMensagens.Clear
LoadMessages(spnFirstName.SelectedItem)
ScrollToLastItem
End Sub
B4X:
Return p
B4X:
Sub Add_Conversation (leftChat As Boolean, name As String, message As String,Phonek As String) As Panel
Private p As Panel
p.Initialize("p")
p.Visible = False
Activity.AddView(p,margin,0,messageSize,5%Y)
p.LoadLayout("Cardchats2")
p.RemoveView
'HERE WE ADD THE MESSAGE AND NAME TO LBNAME AND LBMESSAGE
lbNome.Text = name
lbMensagem.Text = message
Phone.Text=Phonek
Phone.Visible=False
'GET IF IS LEFT OR RIGHT CHAT
If leftChat Then
pWhite.Left = margin
lbNome.Gravity = Bit.Or(Gravity.LEFT,Gravity.CENTER_VERTICAL)
lbMensagem.Gravity = Bit.Or(Gravity.LEFT,Gravity.CENTER_VERTICAL)
Else
pWhite.Left = 100%x - messageSize - margin
lbNome.Gravity = Bit.Or(Gravity.RIGHT,Gravity.TOP)
lbMensagem.Gravity = Bit.Or(Gravity.RIGHT,Gravity.TOP)
End If
'HERE WE GET THE MESSAGE AND NAME CHAT
Private su As StringUtils
lbNome.Top = 0 + internalYMargin
lbNome.Height =su.MeasureMultilineTextHeight(lbNome,lbNome.Text)
lbMensagem.Height =su.MeasureMultilineTextHeight(lbMensagem,lbMensagem.Text)
lbMensagem.Top = lbNome.Top + lbNome.Height
'LATER GET THE CORRECT SIZE NEEDED WE APPLY THIS TO PANEL
p.Height = lbNome.Height + lbMensagem.Height + (internalYMargin * 2)
pWhite.Height = lbNome.Height + lbMensagem.Height + (internalYMargin * 2)
'HERE WE SET THE COLOR AND BORDER TO THE MESSAGE PANEL
If border Then
If leftChat Then
Private cd As ColorDrawable
cd.Initialize2(leftColor,5,borderWidth,borderColor)
pWhite.Background = cd
Else
Private cd As ColorDrawable
cd.Initialize2(rightColor,5,borderWidth,borderColor)
pWhite.Background = cd
End If
Else
If leftChat Then
Private cd As ColorDrawable
cd.Initialize2(leftColor,5,0,borderColor)
pWhite.Background = cd
Else
Private cd As ColorDrawable
cd.Initialize2(rightColor,5,0,borderColor)
pWhite.Background = cd
End If
End If
p.Visible = True
'HERE WE ADD THE CONVERSATION PANEL WITH NAME AND MESSAGE TO CLV
Try
p.RemoveView
clvMensagens.Add(p,p.Height)
Return p
Catch
Log(LastException)
End Try
End Sub
Attachments
Last edited: