Sub Globals Dim Label1 As Label Dim Num1, Num2 As Double Dim Opera As String Dim Cmd(17) As Button End Sub Sub Activity_Create(FirstTime As Boolean) Dim I,L,T,LFT,Top As Int Dim BDB(3) As GradientDrawable Dim BDB1 As StateListDrawable Dim Cols(2) As Int Cols(0)=Colors.RGB(96,128,128) Cols(1)=Colors.RGB(32,0,8) BDB(0).Initialize("TOP_BOTTOM",Cols) BDB(0).CornerRadius=12 BDB(1).Initialize("BOTTOM_TOP",Cols) BDB(1).CornerRadius=5 BDB(2).Initialize("TOP_BOTTOM",Cols) BDB(2).CornerRadius=5 BDB1.Initialize BDB1.AddState(BDB1.State_Disabled,BDB(0)) BDB1.AddState(BDB1.State_Enabled,BDB(1)) BDB1.AddState(BDB1.State_Pressed,BDB(2)) label1.Initialize("") label1.Background=BDB(0) Label1.TextSize =36 Label1.TextColor =Colors.RGB(255,198,198) activity.AddView(Label1,3,4,315,70) For I=0 To 15 L= I Mod 4 T= I / 4 Cmd(I).Initialize("Cmd") Cmd(I).Background =BDB1 Cmd(I).TextSize = 28 Cmd(I).TextColor =Colors.RGB(198,255,255) Activity.AddView(Cmd(I),2+ 80* L,80+ 76*T,77,70) Select I Case 0,1,2,3,4,5,6,7,8,9: Cmd(I).Text = I Case 10: cmd(I).Text ="+" Case 11: cmd(I).Text ="-" Case 12: cmd(I).Text ="X" Case 13: cmd(I).Text ="/" Case 14: cmd(I).Text ="=" Case 15: cmd(I).Text ="Cls" End Select Next Cmd(I).Initialize("Cmd") cmd(I).Background =BDB1 cmd(I).TextSize=34 Cmd(I).TextColor=Colors.RGB(255,64,32) Cmd(I).Text ="Quit" activity.AddView(Cmd(I),2,383,317,70) End Sub Sub Cmd_Down() Dim Str As String Dim Send As Button Send=Sender Str = Send.text Select Str Case "+","-","X","/": Num2=Num1 Opera=Str Str ="0" Num1=0 Case "=": Select Opera Case "" : Return Case "+":Num2 =Num2+Num1 Case "-":Num2 =Num2-Num1 Case "X":Num2 =Num2*Num1 Case "/":Num2 =Num2/Num1 End Select Str =Num2 Case "Cls": Mun1=0 Num2=0 Opera="" Str ="0" Case "Quit": Str="Bye Bye !!!" Activity.Finish Case Else: If Label1.Text <>"0" Then Str =Label1.Text & Str Num1=Str.Replace("Infinity","") End Select Label1.text=Str If Opera="" Then Str=Num1 Else Str=Num2 & " " & Opera & " " & Num1 Activity.Title = Str If str.Length >15 Then label1.TextSize =28 Else label1.TextSize =38 End Sub
源于:http://topic.csdn.net/u/20111028/15/ebd8eb43-5069-4a9e-a1dd-fece37aa1f03.html?seed=686685390&r=76414016#r_76414016