在onResume中,我在线程中设置和更新了recylclerview适配器。在设置或更新之前,请先执行swipeRefreshLayout.setRefreshing(true),然后执行此swipeRefreshLayout.setRefreshing(false)。但是SwipeRefreshLayout的圆圈滞后甚至不可见。
@Override
protected void onResume() {
super.onResume();
swipeRefreshLayout.setRefreshing(true);
new Thread(new Runnable() {
public void run() {
if(first) {
adapter= new Adapter(MainActivity.this, list1, list2, list3, true);
}else{
adapter.update(list1, list2, list3);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
if(first){
recyclerView.setAdapter(adapter);
first = false;
}else {
adapter.notifyDataSetChanged();
}
swipeRefreshLayout.setRefreshing(false);
}
});
}
}).start();
}