Hi! I'm trying to get some data from a web service, and update a label / textarea with some returned values.
I've this code in a view that uses some random URL that simply returns some JSON and I correctly got the data, but I cannot update the label text within the "onReceive" method, while I can correctly do that in the "onLayout".
drw in both cases is an Object, and no error is risen, it simply does nothing, I also tried to simply change the bg color, but the one in onLayout works while the one in onReceive also in this case does nothing.
What I'm doing wrong here?
(Note that the 2 elements are a label and a text-area, but also switching them has no effect, the one in onLayout always works, the one in onReceive doesn't)
Thanks!
function onReceive(response as Lang.Number, responseData as Null or Lang.Dictionary or Lang.String) as Void { var test = responseData[0]["login"]; var drw = self.findDrawableById("mylabel") as Text; drw.setBackgroundColor(Graphics.COLOR_RED); drw.setText(test); } // Load your resources here function onLayout(dc as Dc) as Void { setLayout(Rez.Layouts.myViewLayout(dc)); var url = "https://api.github.com/users/hadley/orgs"; var params = null; var options = { :method => Communications.HTTP_REQUEST_METHOD_GET, :headers => { "Content-Type" => Communications.REQUEST_CONTENT_TYPE_URL_ENCODED, }, }; var onReceiveCallback = method(:onReceive); Communications.makeWebRequest(url, params, options, onReceiveCallback); var drw = self.findDrawableById("BlockOfText") as TextArea; drw.setBackgroundColor(Graphics.COLOR_GREEN); drw.setText("text changed in 'onLayout'"); }