接上一篇 basic4android 使用库下载地址:http://pan.baidu.com/share/link?shareid=2345909338&uk=3993363350
main
Sub Globals
'These global variables will be redeclared each time the activity is created.
'这里声明的变量只能在此模块使用!
Dim my_kbmMW_client As TkbmMWClient
End Sub
Sub Process_Globals
'These global variables will be declared once when the application starts.
'这里声明的变量能被所有模块使用!
Dim sdata As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
'使用可视化界面设计工具设计了界面后,请不要忘记用下面的方法加载你设计的界面(参数是界面文件的名字) o70078汉化 QQ172259743:
Activity.LoadLayout("Main")
End Sub
Sub Button1_Click
Try
my_kbmMW_client.Connect("192.168.1.16",3000)
Dim args(1) As String
args(0)="这里写上你要查的内容"
sdata="结果为"&my_kbmMW_client.SendRequest ("borland","","SELECT",args) ' borland 是你的delphi 那边的接口, SELECT 是delphi 的一个参数
StartActivity(GETSelect)
Msgbox("查询成功","")
第二个页面 GETSelect
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
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
Dim SV As ScrollView
Dim Header As Panel
Dim Footer As Panel
Dim Table As Panel
Dim NumberOfColumns, RowHeight, RowHeight_1, ColumnWidth, ColumnWidth_1 As Int
Dim HeaderColor, LineColor, CellColor, FontColor, HeaderFontColor As Int
Dim ColLineWidth, RowLineWidth As Int
Dim FontSize As Float
Type RowCol (Row As Int, Col As Int)
Dim Alignment As Int
Dim SelectedRow As Int
Dim SelectedRowColor As Int
: SelectedRowColor=Colors.LightGray
'Table settings
HeaderColor = Colors.Gray
NumberOfColumns = 4 'will be overwritten when loading from CSV file.
ColLineWidth = 1dip
RowLineWidth = 1dip
RowHeight_1 = 30dip
RowHeight=RowHeight_1+RowLineWidth
LineColor = Colors.Black
CellColor = Colors.White
FontColor = Colors.Black
HeaderFontColor = Colors.White
FontSize = 14
Alignment = Gravity.CENTER 'change to Gravity.LEFT or Gravity.RIGHT for other alignments.
End Sub
Sub Activity_Create(FirstTime As Boolean)
SV.Initialize(0)
' SV.Color=Colors.Transparent
SV.Panel.Color=Colors.Black
Table = SV.Panel
Table.Color = LineColor
Activity.AddView(SV, 1%x, 10%y, 99%x, 80%y)
ColumnWidth = SV.Width / NumberOfColumns
ColumnWidth_1 = ColumnWidth-ColLineWidth
SelectedRow = -1
loadxinxi(Main.sdata)
End Sub
Sub loadxinxi(s As String)
Dim JSON As JSONParser
Dim Master As Map
Dim records As List
Dim XINXI As Map
Dim recordcount As String
ClearAll
Dim h(4) As String
h(0)="序号"
h(1)="姓名"
h(2)="学院"
h(3)="个人"
NumberOfColumns = h.Length
ColumnWidth = SV.Width / NumberOfColumns 'update the columns widths
ColumnWidth_1 = ColumnWidth-ColLineWidth
SetHeader(h)
JSON.Initialize(s)
'Master = JSON.NextObject
'records=Master.Get("topics")
records = JSON.NextObject
'records=Master.Get("topics")
Dim data(4) As String
For i=0 To records.Size-1
Dim row() As String
XINXI=records.Get(i)
data(0)=XINXI.Get("bm")
data(1)=XINXI.get("mc")
data(2)=XINXI.get("xm")
data(3)=XINXI.get("lx")
row =data
AddRow(row)
Next
recordcount=Master.Get("totalCount")
h(0)="合计"
h(1)=recordcount
h(2)=""
h(3)=""
SetFooter(h)
Activity.Title="职工信息"
End Sub
Sub Cell_Click
Dim rc As RowCol
Dim l As Label
Dim l0 As Label
l = Sender
rc = l.Tag
SelectRow(rc.Row)
l0=GetView(rc.Row,0)
'activity.Title = "Cell clicked: (" & rc.Row & ", " & rc.Col & l0.Text &")"
'myxh=l0.Text
End Sub
Sub Header_Click
Dim l As Label
Dim col As Int
l = Sender
col = l.Tag
Activity.Title = "Header clicked: " & col
End Sub
Sub SelectRow(Row As Int)
'remove the color of previously selected row
If SelectedRow > -1 Then
For col = 0 To NumberOfColumns - 1
GetView(SelectedRow, col).Color = CellColor
Next
End If
SelectedRow = Row
For col = 0 To NumberOfColumns - 1
GetView(Row, col).Color = SelectedRowColor
Next
End Sub
'Returns the label in the specific cell
Sub GetView(Row As Int, Col As Int) As Label
Dim l As Label
l = Table.GetView(Row * NumberOfColumns + Col)
Return l
End Sub
'Adds a row to the table
Sub AddRow(Values() As String)
If Values.Length <> NumberOfColumns Then
Log("Wrong number of values.")
Return
End If
Dim lastRow As Int
lastRow = NumberOfRows
For i = 0 To NumberOfColumns - 1
Dim l As Label
l.Initialize("cell")
l.Text = Values(i)
l.Gravity = Alignment
l.TextSize = FontSize
l.TextColor = FontColor
l.Color=Colors.White
Dim rc As RowCol
rc.Initialize
rc.Col = i
rc.Row = lastRow
l.Tag = rc
Table.AddView(l, ColumnWidth * i, RowHeight * lastRow, ColumnWidth_1, RowHeight_1)
Next
Table.Height = NumberOfRows * RowHeight
End Sub
'Set the headers values
Sub SetHeader(Values() As String)
If Header.IsInitialized Then Return 'should only be called once
Header.Initialize("")
For i = 0 To NumberOfColumns - 1
Dim l As Label
l.Initialize("header")
l.Text = Values(i)
l.Gravity = Gravity.CENTER
l.TextSize = FontSize
l.Color = HeaderColor
l.TextColor = HeaderFontColor
l.Tag = i
Header.AddView(l, ColumnWidth * i, 0, ColumnWidth_1, RowHeight_1)
Next
Activity.AddView(Header, SV.Left, SV.Top - RowHeight, SV.Width, RowHeight)
End Sub
Sub SetFooter(Values() As String)
If Footer.IsInitialized Then Return 'should only be called once
Footer.Initialize("")
For i = 0 To NumberOfColumns - 1
Dim l As Label
l.Initialize("footer")
l.Text = Values(i)
l.Gravity = Gravity.CENTER
l.TextSize = FontSize
l.Color = HeaderColor
l.TextColor = HeaderFontColor
l.Tag = i
Footer.AddView(l, ColumnWidth * i, 0, ColumnWidth_1, RowHeight_1)
Next
Activity.AddView(Footer, SV.Left, SV.Top+SV.Height, SV.Width, RowHeight)
End Sub
Sub NumberOfRows As Int
Return Table.NumberOfViews / NumberOfColumns
End Sub
'Sets the value of the given cell
Sub SetCell(Row As Int, Col As Int, Value As String)
GetView(Row, Col).Text = Value
End Sub
'Gets the value of the given cell
Sub GetCell(Row As Int, Col As Int) As String
Return GetView(Row, Col).Text
End Sub
'Clears the table
Sub ClearAll
For i = Table.NumberOfViews -1 To 0 Step -1
Table.RemoveViewAt(i)
Next
Table.Height = 0
SelectedRow = -1
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Catch
Msgbox("无法链接","")
End Try
End Sub
可能写得不够好, 如果不懂 者 可以 参考 : http://www.51delphi.com 、 http://www.cnblogs.com/xalion