LiveData更新数据报错解决方法java.lang.IllegalStateException: Cannot invoke setValue on a background thread
将setValue(T)改为postValue(T)即可。
原因:
setValue(T) 必须在主线程中调用 , 而 postValue(T) 既可以在主线程中调用, 也可以在子线程中调用
参考博客:
https://blog.csdn.net/xingxtao/article/details/89424110