我正在使用 RecyclerView,其中我有行数,每行都有更新的进度条。前四行可见。当行数大于 4 时,我在我的 recyclerview 上调用 getChildAt(pos) 来获取 View ,它返回空值。请帮忙。
最佳答案
由于 recyclerView.getChildAt(position) 在上面的场景中给了我 null ,我最终使用下面的代码解决了问题。它对遇到类似情况的人很有用。
RecyclerView.ViewHolder holder = (RecyclerView.ViewHolder)
recyclerView.findViewHolderForAdapterPosition(position);
if (null != holder) {
holder.itemView.findViewById(R.id.xyz).setVisibility(View.VISIBLE);
}
关于android - getChildAt(pos) 在 RecyclerView 上返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41764601/