0

I was going to set the background of a linear layout from the server URL.

On the main thread, I couldn't get images from the server.

On the AsyncTask, I couldn't set the background of the linear layout.

How can I solve this problem?

Thank you.

webelf000
  • 147
  • 9

2 Answers2

0

Activities had a runOnUiThread(Runnable action) method where you can update the UI.

AsyncTask:

@Override
protected void onPostExecute(String result) {
    listener.updateUi()
}

Activity:

@Override
public void updateUi(String result){
    runOnUiThread(() -> {
        // Change the UI here     
    });
}
aiqency
  • 1,015
  • 1
  • 8
  • 22
0

I solved the problem just as follows by myself.

Thank you for your help.

https://stackoverflow.com/a/9963705/12817071

webelf000
  • 147
  • 9