I do not triggered the click event in custom dialog

alan1968

Active Member
Licensed User
Longtime User
hello
In the panel of scrollview to custom dialog,I have a button but I do not triggered the click event to display a different panel

my code
B4X:
Sub Process_Globals
   

End Sub

Sub Globals   
   Dim scv As ScrollView
   Dim Panel1,panel2,panel3 As Panel
   Dim data_tmp(15) As EditText
   Dim selection,idx As Int
   Dim cd As CustomDialog2
   Dim Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
Dim GD As GradientDrawable
GD.Initialize("BR_TL", Array As Int(Colors.Yellow, Colors.LightGray))
Panel1.Initialize("panel1")
Panel1.Background= GD
Activity.AddView(Panel1, 0, 0, 100%x, 100%y)
show_CustomDialog
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub show_CustomDialog
Dim lgn() As String
Dim lg() As Int
Dim label_t(10) As Label
Dim titre As String
Dim ret As Int
lgn = Array As String("1:", "2:","3","4:","5:","6","7","")
lg =Array As Int(100dip, 100dip,100dip,100dip,100dip,100dip,100dip,100dip)
titre="mon titre"
'button 
Button1.Initialize("Button")
Button1.Text="8"
panel2.Initialize("panel2")
panel2.AddView(Button1,0dip,370dip, 70dip, 50dip)
For i= 0 To 7
label_t(i).Initialize ("label_t")
label_t(i).Text=lgn(i)
data_tmp(i).Initialize("label_tmp")
data_tmp(i).InputType=data_tmp(i).INPUT_TYPE_NUMBERS
data_tmp(i).SingleLine=True
data_tmp(i).Text="0"
panel2.AddView(label_t(i),5dip, 30dip+50dip*i , 150dip, 40dip)
panel2.AddView(data_tmp(i),90dip, 25dip+50dip*i , lg(i), 40dip)
Next
scv.Initialize(1000dip)
scv.panel.AddView(panel2,0,0,77%x,30dip+50dip*i)
scv.panel.Height = panel2.Height
cd.AddView(scv,77%x, 60%y) 
ret = cd.show(titre, "OK", "CANCEL", "",Null)
If ret=-1 Then
'ok
Else
'cancel
End If
End Sub

Sub Button_Click
Dim GD As GradientDrawable
scv.FullScroll(False)
scv.Visible=False
panel3.Initialize("panel3")
GD.Initialize("TR_BL", Array As Int(Colors.DarkGray, Colors.LightGray))
panel3.Background= GD
cd.AddView(panel3,77%x,60%y)
End Sub

THX! ALAN
 

stevel05

Expert
Licensed User
Longtime User
If the Button is called Button1 then the sub should be Button1_Click.

Steve
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
If the Button is called Button1 then the sub should be Button1_Click.

Steve

Steve, he initialised it as:
B4X:
Button1.Initialize("Button")
So the event will be Button_Click.

However, I am not sure how a custom dialog will allow new panels to be created.

Try creating the panel in the first showdialog sub, but just making it visible on click.
 
Upvote 0

yuhong

Member
Licensed User
Longtime User
I also encountered the same problem, ONClick events, and sometimes trigger, and sometimes does not trigger.
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
Is it possible that the panel is receiving the touch?

Regards Ricky
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…