Runnable is posted successfully but not run

后端 未结 6 1577
别跟我提以往
别跟我提以往 2020-12-08 07:45

In an existing Android project I\'ve encountered the following piece of code (where I inserted the debugging litter)

ImageView img = null;

public void onCre         


        
6条回答
  •  轮回少年
    2020-12-08 08:27

    I had the same problem, and using view.getHandler() also failed because the handler was not present. runOnUiThread() solved the problem. Presumably this does actually do some queueing until the UI is ready.

    The cause for me was calling the icon load task in a base class and the result being returned so quickly that the main class hadnt estabished the view (getView() in fragment).

    I'm a bit suspicious that it might spuriously fail sometime. But I'm now ready for it! Thanks guys.

提交回复
热议问题