【问题标题】:With ConcatAdapter RecyclerView began flickering随着 ConcatAdapter RecyclerView 开始闪烁
【发布时间】:2022-01-18 08:36:33
【问题描述】:

我在之前的列表(字符串数据和 ImageView)之前实现了额外的 webview,并将它们与 ConcatAdapter 连接起来。

现在我有了以前的适配器(数据列表)、附加的新适配器(webview)和适配器 ConcatAdapter。

但是任何点击和任何使用 notifyDataSetChanged 看起来都像是刷新所有 UI。 我试过了

((SimpleItemAnimator) recyclerViewList.getItemAnimator()).setSupportsChangeAnimations(false);

但没有帮助。 什么可以帮助 UI 闪烁?

第一个适配器上的数据列表有字符串数据和ImageView,并且大多是闪烁的ImageView。 在 webview ImageView 工作正常之前。

【问题讨论】:

  • 通知项改变了怎么办?通知项目已更改

标签: android android-recyclerview concatenation adapter notifydatasetchanged


【解决方案1】:

很多小时但非常简单的解决方案:

ConcatAdapter.Config config = new ConcatAdapter.Config.Builder()
     .setStableIdMode(ConcatAdapter.Config.StableIdMode.SHARED_STABLE_IDS).build();
adapter1.setHasStableIds(true);
adapter2.setHasStableIds(true);
concatAdapter = new ConcatAdapter(config, adapter1, adapter2);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-01
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    • 2012-04-19
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    相关资源
    最近更新 更多