我面临着在调用adapter.notifyDataSetChanged()或adapter.notifyItemRangeChanged(0,recyclerView.getChildCount())时适配器闪烁的问题。我已经尝试了很多解决方案,比如setHasStableIds(true)和重写getItemId()来返回id,但这对我没有帮助。
if (page == 1) {
homeAdapter = new HomeAdapter(getActivity(), homeBeanList, Home.
this, Home.
this, Home.
this, profile_pic, Home.
this, Home.
this, page);
loaderDiloag.dismissDiloag();
recyclerView.setAdapter(homeAdapter);
recyclerView.setNestedScrollingEnabled(false);
} else {
if (homeAdapter != null) {
try {
loaderDiloag.dismissDiloag();
recyclerView.setNestedScrollingEnabled(false);
homeAdapter.notifyItemRangeChanged(0, recyclerView.getChildCount());
} catch (Exception e) {
Log.e("error", e.toString() + "");
}
} else {
try {
homeAdapter = new HomeAdapter(getActivity(), homeBeanList, Home.
this, Home.
this, Home.
this, profile_pic, Home.
this, Home.
this, page);
loaderDiloag.dismissDiloag();
recyclerView.setAdapter(homeAdapter);
recyclerView.setNestedScrollingEnabled(false);
homeAdapter.notifyDataSetChanged();
} catch (Exception e) {
Log.e("error", e.toString() + "");
}
}发布于 2018-08-15 14:15:35
尝尝这个
private void removeBlinkAnimationWhenNewItemAdded(){
((SimpleItemAnimator)recyclerView).setSupportsChangeAnimations(false)
}https://stackoverflow.com/questions/51853638
复制相似问题