M
M
max_vr2016-05-21 13:46:21
Java
max_vr, 2016-05-21 13:46:21

How can I make the TextView.setText() method wait for a response?

The situation is this: there is a connect class, it has a String getData(String _encoding, String _url) method, which sends a get request to the specified url and returns a response, is launched via AsyncTask. There is an activity with a text field, at the start of which a get request should be sent automatically, and the answer should be displayed in the text field. How can I make the setText method not fire until the get request completes?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2016-05-21
@GavriKos

Do setText in onPostExecute of your AsyncTask.

I
IceJOKER, 2016-05-21
@IceJOKER

How I do it - I add an interface, implement it in an activity, and call it in onPostExecute AsyncTask )
https://xelsoft.wordpress.com/2014/11/28/asynctask... - here is an example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question