Handle events and passing Activity

rossati

Active Member
Licensed User
Longtime User
Hello

I have just started working on Basic4Android and I have (many questions), particularly I haven't yet found a system for passing activity to a module, e.g. this is not working:


Dim act As Activity
dataParams = "Title,,25,T,%chart %date;" _
& "Border,,10,B,Start;" _
& "Type,Graphic Type,10,T,Line,Bubble|Delta|Line;" _
& "Graph,,10,T;" _
& "psw,Password,10,P"
act = Activity.LoadLayout("main")
formhandler.prova(act)
...
Sub prova(act As Activity)
Dim btn As Button
btn.Initialize("butun")
btn.Text = "butun"
act.AddView(btn,0,0,100,100)
End Sub

Besids I have another question, i.e. I would handle events in order tu create a function wich build a form an return data when one click on button.

Thanks for suggestions

John Rossati
 

rossati

Active Member
Licensed User
Longtime User
Thanks

I went over, but I found another obstacle i.e. I found this error (the statement is in code module):

Error description: Process object is expected. {Type=EditText,Rank=0} is an Activity object.
Declaring the variable in Sub Globals instead of Sub Process_Globals will solve this problem.
Occurred on line: 32
widgetRef.Put("xxxxx",btn)
Word: btn

The code fragment interested is:

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
'Dim Buttons(32) As Button
Dim Elem As Map ' data fields
Dim nElem As Int ' Elements number
Dim widgetRef As Map ' Reference to widget of data
End Sub
Sub prova(act As activity)
Dim widgetRef As Map ' Reference to widget of data
Dim btn As EditText
widgetRef.Initialize
btn.Initialize("butun")
btn.TextSize = 12
btn.Text = "butun"
act.AddView(btn,0,0,100,100)
widgetRef.Put("xxxxx",btn)
End Sub

(This does not happen if this statement is in the Activity module)
Furthermore, the code module doesn't contains Sub Globals and does not accept.
I forgot to say that I can not put the Declaration in Activity module.

Best regards

John Rossati
 
Upvote 0
Top