Problem with CustomDialog2

D

Deleted member 103

Guest
Hi,

I have a problem with the "Dialog.CustomDialog2.
If I switch the "Show CustomDialog2" for the second time then I get this error message:
"java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first."

What am I doing wrong?

Ciao,
Filippo
 

Attachments

  • CustomDialog2.zip
    6.8 KB · Views: 284
  • CustomDialog2_1.jpg
    CustomDialog2_1.jpg
    36.2 KB · Views: 314
  • CustomDialog2_2.jpg
    CustomDialog2_2.jpg
    68.5 KB · Views: 342

agraham

Expert
Licensed User
Longtime User
B4X:
Sub btnCustomDialog2_click
   Dim cd As CustomDialog2
   [COLOR="Red"]cd.AddView(pnlNumericUpDown,160dip,50dip)[/COLOR]
   cd.Show("Spielschein-Auswahl","OK","Abbrechen","",Null)
   If cd.Response=-1 Then
      Dim n As Int
      n=txtBox.text
      Msgbox(n,"Test")
      'SchowSpielSchein(n - 1)
   End If
End Sub
You are adding a Panel that has already been added before and so already has a parent. If you used a newly created local Panel each time there would be no problem. However in order to allow such reuse of an existing Panel Dialogs version 2.3 now internally removes the Panel on closure allowing such reuse.
 
Upvote 0
D

Deleted member 103

Guest
Hi agraham,

I still have a problem.
Do you know why my sub "btnUpDown_LongClick" does not work?

PHP:
Sub btnUpDown_LongClick
   Dim btn As Button
   btn=Sender
   txtBox=btn.Tag
   If btn.Text="+" Then
      blnNumericUpDownAdd=True
   Else
      blnNumericUpDownAdd=False
   End If
   timerNumericUpDown.Enabled = True
End Sub

Sub timerNumericUpDown_Tick
   Dim lst As List
   Dim n As Int
   n=txtBox.Text
   
   lst=txtBox.Tag
   If blnNumericUpDownAdd Then
      If n < lst.Get(1) Then n=n + 1
   Else
      If n > lst.Get(0) Then n=n - 1
   End If
   txtBox.Text = n
End Sub
Thanks,
Filippo
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Your LongClick event is working fine from within the dialog, it is the Timer event that is not firing. I think this is because the modal dialog mechanism in Basic4android will not despatch B4ARunnables while the dialog is shown. I'm not absolutely sure as I can't immediately see that the timer uses a B4ARunnable to raise the event, it looks like a normal Runnablebut it seems likely that this or something very similar is the reason.

@Erel. Is this right? TickTack looks like a normal Runnable not a B4ARunnable. :confused:
 
Upvote 0
D

Deleted member 103

Guest
@agraham
how do we proceed?
Now so you will add a function in your library?(that would be great)
 
Upvote 0
D

Deleted member 103

Guest
Proceed with what?
it would be best if you would add the function "NumericUpDown" in your dialog-library.
Then we would have no problem with the "Timer ".;)
 
Upvote 0
Top