Displaying HTTP response in EditText?

JogiDroid

Member
Licensed User
Longtime User
I have just couple of hours learning about B4A in my back so this might be easy...

I'm trying to display HTTP response to EditText.. but it seems that I can not read or write my Etext.text in "HttpClient1_ResponseSuccess()"???

B4X:
Sub Globals
   Dim Button1 As Button
   Dim Etext As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
      HttpClient1.Initialize("HttpClient1")
   End If
   
   Activity.LoadLayout("layout1")

   Etext.Initialize("")
End Sub


Sub HttpClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
   Log("ResponseSuccess")
   ProgressDialogHide
   Dim result As String
   result = Response.GetString("UTF8") 'Convert the response to a string
   Log(result) ' Shows fine
   Log("1Etext.Text " & Etext.Text) ' Shows just "1Etext.text" but not actual Text..which should be just "test1"
   Etext.Text = result
   Log("2Etext.Text " & Etext.Text) ' now all is shown but nothing shows in actual EditText view
   Etext.Invalidate ' needed?? yes, no??
   Log("3Etext.Invalidate")
End Sub




edit1: Ok, somehow I thought that I have to do Etext.Initialize("") in Activity_Create() but after I did not do that text started to display right away.. In same time I removed Etext.Invalidate and it worked still ok... So when to Initialize and when to Invalidate is needed???
 
Last edited:
Top