'clsCustomButton
Sub Class_Globals
Private mName As String
Private mIRCode As String = ""
Private mButton As Button
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(act As Activity, left As Int, top As Int, width As Int, height As Int, name As String, label As String)
mName = name
mButton.Initialize("button")
mButton.Text = label
act.AddView(mButton, left, top, width, height)
End Sub
Public Sub getIRCode() As String
Return mIRCode
End Sub
Public Sub setIRCode(code As String)
mIRCode = code
End Sub
Public Sub getNamne() As String
Return mName
End Sub
Private Sub button_Click
Log($"You clicked button ${mName}"$)
End Sub
'Main Activity
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private cButton(2) As clsCustomButton
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
cButton(0).Initialize(Activity, 10dip, 10dip, 120dip, 40dip, "Button 1", "Tap Me")
cButton(1).Initialize(Activity, 10dip, 60dip, 120dip, 40dip, "Button 2", "Tap Me")
cButton(0).IRCode = "ABCD1234"
Log(cButton(0).IRCode)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub PopulateTagList()
Dim ls As List
ls.Initialize
DBUtils.ExecuteList2(SQL1,"SELECT Button FROM IR_codes",Null,0,ls)' Button name property
For i = 0 To ls.Size - 1
Private tmptext As String
tmptext = ls.Get(i)
' iterate trough buttons and put IR_code in button.tag when NAME MATCH IS FOUND
For j = 0 to cButton.Length - 1
If cButton(j).Name = tmpText Then
cButton(j).IRCode = 'whatever your IR code is
End If
Next
Log(tmptext)
Next
End Sub
[CODE]
You get the general idea...
- Colin.