findLastVisibleItemPosition
按以下顺序返回-1:
onViewCreated() {
recyclerView.setAdapter(adapter = new Adapter());
adapter.updateContent(List<Content>); // will call notifyItemRangeChanged
post(new Runnable() {
run() {
layoutManager.getLastVisibleItem(); // == -1 (using runnable or not)
}
}
}
似乎儿童观点还没有准备好。使用RecyclerView
上的树观察器似乎可以解决问题,但是在创建后立即将内容设置到适配器后获取最后一个可见项的最佳方法是什么?