当我想将一些新数据设置到我的RecyclerView. firsTime它的OK,但是当我想刷新我RecyclerView(在我的代码段其他)出现此错误。我知道此错误将用于RecyclerView.Animation并查看此代码:
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
我把这段代码放在我的片段中onCreateView,对不起,我的问题没有解决。
谁能告诉我出了什么问题?谢谢。
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_distance_report_lists, container, false);
RecyclerView recyclerView = new RecyclerView(view.getContext());
//((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
if (TextUtils.isEmpty(distance)) {
recyclerView.setAdapter(new RecyclerViewAdapterDistance(jCars, cntx));
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
} else {
recyclerView.setAdapter(new RecyclerViewAdapterDistance(cntx, fromDate, fromTime, toDate, toTime, distance, jCars));
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
}
return recyclerView;
}
GCT1015
慕哥9229398
相关分类