'Activity module
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.
Dim a As MYSQL
Dim L As List
Dim hsv As HorizontalScrollView
Dim svRows As ScrollView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'write your own parameters
'a.setDatabase("server ipnumber (not name)","databasename","username","password") 'Cancel this line
'you can write named server
a.setDatabase("server ipnumber or url","databasename","username","password")
' select query
' L=a.Query("select * from tb_Test")
' or get table list for database
L = a.TableList 'you can get all tables for default database
' CUD: Create, Update, Delete
' or UPDATE query
' Dim r as Int ' return affected rows count
' r = a.ExecuteNonQuery("update tablename set fieldname='xxxx' where keyname='xx'; ")
If L.IsInitialized=False Then
Msgbox("Records Not Found","Warning")
Return
End If
Dim row As List,cols As Int ,rows As Int
rows = L.Size
row = L.Get(0) 'Header row
cols = row.Size
hsv.Initialize(cols*150dip,0)
Activity.AddView(hsv,0,0,100%x,100%y)
svRows.Initialize(rows*30dip)
hsv.Panel.AddView(svRows,0,30dip,cols*150dip,100%y-30dip)
'CREATE HEADER LABELS
For j=0 To cols-1
hsv.Panel.AddView(LabelCreate(row.Get(j),Colors.DarkGray,Colors.White) _
,j*150dip _
,0 _
,149dip _
,29dip)
Next
'CREATE RECORD LABELS
For i=1 To L.Size-1
row = L.Get(i)
For j=0 To cols-1
svRows.Panel.AddView( LabelCreate(row.Get(j),Colors.LightGray,Colors.Black) _
,j*150dip _
,i*30dip-30dip _
,149dip _
,29dip)
Next
Next
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub LabelCreate(str As String,backcolor As Int,textcolor As Int) As Label
Dim t As Label
t.Initialize(0)
t.text=" " & str
t.color=backcolor
t.textcolor=textcolor
t.Gravity = Gravity.CENTER_VERTICAL
Return t
End Sub