RecyclerView日志语句:W/RecyclerView:RecyclerView不支持滚动到绝对位置.改用scrollToPosition [英] RecyclerView log statement: W/RecyclerView: RecyclerView does not support scrolling to an absolute position. Use scrollToPosition instead
问题描述
我正在更新一个旧的Android项目,现在我反复从RecyclerView获取此日志语句:
I am updating an old Android project, and now I am getting this log statement from RecyclerView repeatedly:
W/RecyclerView: RecyclerView does not support scrolling to an absolute position. Use scrollToPosition instead
第一次填充和显示recyclerview或刷新recyclerview中的项目时,就会发生这种情况.
It occurs when the recyclerview is populated and displayed for the first time or when the items in the recyclerview are refreshed.
Logcat:
11-05 14:02:23.290 20209-20209/com.mydomain W/RecyclerView: RecyclerView does not support scrolling to an absolute position. Use scrollToPosition instead
11-05 14:02:23.290 20209-20209/com.mydomain W/RecyclerView: RecyclerView does not support scrolling to an absolute position. Use scrollToPosition instead
11-05 14:02:23.607 20209-20209/com.mydomain W/RecyclerView: RecyclerView does not support scrolling to an absolute position. Use scrollToPosition instead
11-05 14:02:23.607 20209-20209/com.mydomain W/RecyclerView: RecyclerView does not support scrolling to an absolute position. Use scrollToPosition instead
11-05 14:02:23.629 20209-20209/com.mydomain W/RecyclerView: RecyclerView does not support scrolling to an absolute position. Use scrollToPosition instead
[...]
该行重复大约40次以上
The line repeats about 40+ times
但是,据我所知,在我的代码中,我并没有滚动到绝对位置. (除非它可能是其他东西的副产品)
However, as far as I can tell, in my code I am not scrolling to an absolute position. (Unless perhaps it is a byproduct of something else)
我无法找到有关此警告的很多信息.
I have not been able to find much information about this warning.
任何人都可以提供见解吗?
Can anyone provide insight?
推荐答案
将此行放入Adapter构造函数,也许对您有用:
Put this line in Adapter constructor, maybe it'll work for you:
this.setHasStableIds(true);
这篇关于RecyclerView日志语句:W/RecyclerView:RecyclerView不支持滚动到绝对位置.改用scrollToPosition的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!