首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当调用notifyDataSetChanged()时,RecyclerView闪烁

当调用notifyDataSetChanged()时,RecyclerView闪烁
EN

Stack Overflow用户
提问于 2018-08-15 13:59:20
回答 1查看 1.5K关注 0票数 2

我面临着在调用adapter.notifyDataSetChanged()adapter.notifyItemRangeChanged(0,recyclerView.getChildCount())时适配器闪烁的问题。我已经尝试了很多解决方案,比如setHasStableIds(true)和重写getItemId()来返回id,但这对我没有帮助。

代码语言:javascript
运行
复制
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() + "");
        }
    }
EN

Stack Overflow用户

发布于 2018-08-15 14:15:35

尝尝这个

代码语言:javascript
运行
复制
private void removeBlinkAnimationWhenNewItemAdded(){
        ((SimpleItemAnimator)recyclerView).setSupportsChangeAnimations(false)
}
票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51853638

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档