Popup Question - illegal java class error on "Sender"

roarnold

Active Member
Licensed User
Longtime User
All,

I am programmaticaly build this but I receive a java class error on the "Sender" statement when trying to set "btn = Sender". Any ideas?

/Code

Sub btnpop
Dim pnl4 As Panel
pnl4.Initialize(pnl4)
Dim cld As ColorDrawable
cld.Initialize ( Colors.RGB( 135, 206, 250) , 5dip )

pnl4.Background = cld


Dim lbl As Label
lbl.Initialize(lbl)
lbl.TextColor = Colors.Black '(pnl3.Color)
lbl.Text = " Want to Reload? "


Activity.AddView(pnl4, 80dip, 110dip, 180dip, 100dip)
Activity.AddView(lbl,90dip, 120dip, 200dip, 150dip)

btn10.Initialize("btn10")
btn10.Tag = "10"
btn10.Text = "No"
btn10.TextSize = 10
Activity.AddView(btn10,90dip, 160dip, 60dip, 40dip)
btn11.Initialize("btn11")
btn11.Tag = "11"
Log(btn11.Tag)
btn11.Text = "Yes"
btn11.TextSize = 10
Activity.AddView(btn11,180dip, 160dip, 60dip, 40dip)


pop

End Sub
Sub pop
Dim btn As Button
btn = Sender

Log(btn.Tag)
Select btn.Tag
Case "10"

Log("No")

Return

Case "11"
Log("Yes")
Activity.Finish
Activity.RemoveView
End Select
End Sub

Code/
 

stevel05

Expert
Licensed User
Longtime User
Yes, you cant call the sub pop like that, presumably sender is null at that point. It has to be called in response to a view (button in this case) click.

You need to initialize the buttons like this:

B4X:
btn11.initalize("pop")

all to the same subroutine and then rename the sub pop to pop_Click and remove your call to pop.

It should then do what you expect.
 
Last edited:
Upvote 0
Top