Loading... 在Fragment中使用getActivity().runOnUiThread()更新Ui可能会遇到报错: >java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.support.v4.app.FragmentActivity.runOnUiThread(java.lang.Runnable)’ on a null object reference at com.rehtt.app.Fragment.MainFragment$3.onFailure(MainFragment.java:103) 这是因为getActivity()为null所致。 解决方法: ```java if (getActivity() !=null ){ getActivity().runOnUiThread(......); } ``` Last modification:October 24, 2019 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 如果觉得我的文章对你有用,请随意赞赏