本文介绍了当notifyDataSetChanged时,RecyclerView中的WebView将闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的RecyclerView中有一个WebView,每当我呼叫RecyclerView.notifyDataSetChanged时,WebView都会短暂闪烁.

I have a WebView in my RecyclerView, whenever I call RecyclerView.notifyDataSetChanged the WebView will have a short flashing.

我不希望WebView发生任何变化,我该怎么做?

I don't want any changes happen on the WebView, how can I do this ?

我知道我可以使用notifyItemXXX而不是notifyDataSetChanged来解决此问题.但是我确实需要notifyDataSetChanged方法.

I know I can solve this with using notifyItemXXX instead of notifyDataSetChanged. But I do need notifyDataSetChanged method.

推荐答案

notifyDataSetChanged()官方文档说:将迫使LayoutManagers完全重新绑定并重新布局所有可见视图."因此,我认为网络视图的闪烁是由此引起的.并且您可以找到此作为最后的手段依靠onnotifyDataSetChanged()".正如您提到的那样,您必须使用此方法,所以请您提供更多信息,以便我帮助您找到更好的解决方案.

As thenotifyDataSetChanged() official doc says "LayoutManagers will be forced to fully rebind and relayout all visible views.". So I think the webview's flash is caused by this. And you can find this "Rely onnotifyDataSetChanged() as a last resort.".As you mentioned you must use this method, so can you please give more info so I can help you to find out a better solution.

这篇关于当notifyDataSetChanged时,RecyclerView中的WebView将闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 02:25