i use array to make button,
how i identify that button i click?
B4X:
dim button(13) as button
for i = 0 to 13 -1
but(i).Initialize("But")
Activity.AddView(but(i),10%x + (i*11.5%x),14.5%y,11.5%x,8.3%y)
next
sub but(0)_click 'error in here
msgbox("test","test")
end sub
dim buttons(13) as button
for i = 0 to 13 -1
buttons(i).Initialize("buttons")
buttons(i).tag = i
next
sub buttons_click
dim b as button = sender
bid = b.tag
b(btag).enable = false
end sub
i want buttons(0) can disable buttons(3) or buttons(5)
I suppose the problem is that you are not declaring the buttons as Global variables. You must do so to be able to use them in the "buttons_click" event
B4X:
Sub Globals
Dim buttons(13) as button
end sub
Sub Activity_Create(FirstTime as Boolean)
for i = 0 to 13 -1
buttons(i).Initialize("buttons")
buttons(i).tag = i
next
end sub
Sub buttons_click
dim b as button = sender
bid = b.tag
if bid=0 then
buttons(3).enable=false
buttons(5).enable=false
endif
end sub
I suppose the problem is that you are not declaring the buttons as Global variables. You must do so to be able to use them in the "buttons_click" event
B4X:
Sub Globals
Dim buttons(13) as button
end sub
Sub Activity_Create(FirstTime as Boolean)
for i = 0 to 13 -1
buttons(i).Initialize("buttons")
buttons(i).tag = i
next
end sub
Sub buttons_click
dim b as button = sender
bid = b.tag
if bid=0 then
buttons(3).enable=false
buttons(5).enable=false
endif
end sub