我的活动显示RecyclerView带有LinearLayoutManager. 我想获得View列表中的第一项 ( )。根据这篇文章接受的答案,我可以调用LinearLayoutManager.findViewByPosition()方法,但我得到null了。为什么?
RecyclerView list = findViewById(R.id.list);
LinearLayoutManager llm = new LinearLayoutManager(this);
list.setLayoutManager(llm);
MyAdapter adapter = new MyAdapter();
list.setAdapter(adapter);
View firstViewItem = llm.findViewByPosition(0); // <-- null
adapter包含项目,它不为空。