我有这个代码
public class CustomLinearLayoutManager extends LinearLayoutManager
{
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state)
{
super.onLayoutChildren(recycler, state);
int childCount = getChildCount();
View lastChild = getChildAt(childCount - 1);
// Do some stuff
}
}由于某些原因,有时lastChild是null。怎么会这样呢?
正如评论中提到的,lastChild是空的,因为根本没有childs,所以新的问题是,为什么在调用super.onLayoutChildren(recycler, state);之后没有childs
发布于 2016-09-08 20:13:34
由于某些原因,似乎没有具有此布局的视图具有父级。你能发布你的xml吗?
https://stackoverflow.com/questions/39390486
复制相似问题