'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim PostUrl As String
PostUrl = "http://142.114.2.131/Sitios/HolaMundo/HolaMundo.asmx?op=Lista"
Dim parser As SaxParser
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 Lista As ListView
Dim TxtBox1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
HttpUtils.CallbackActivity = "Main"
End Sub
Sub Activity_Resume
If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub TxtBox1_EnterPressed
Dim parametro As String
parametro = TxtBox1.Text
LlamarFuncion(parametro)
End Sub
Sub LlamarFuncion(parametro As String)
ProgressDialogShow("Buscando. . .")
HttpUtils.PostString("POST Job1", PostUrl, parametro)
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.CallbackUrlDoneSub = "UrlDone"
End Sub
Sub UrlDone(Url As String)
Log(Url & " done")
ProgressDialogHide
End Sub
Sub JobDone (Job As String)
Select Job
Case "POST Job1"
Dim cadena As InputStream
If HttpUtils.IsSuccess(PostUrl) Then
cadena = HttpUtils.GetInputStream(PostUrl)
'Log(HttpUtils.GetString("http://www.b4x.com/print.php"))
parser.Parse(cadena, "Parser")
cadena.Close
End If
End Select
HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
For i = 0 To parser.Parents.Size
Lista.AddSingleLine(parser.Parents.Get(i))
Next
End Sub