My Activity is showing a RecyclerView
with a LinearLayoutManager
. I want to get the first item (View
) in the list. According this post's accepted answer , I can do it calling LinearLayoutManager.findViewByPosition()
method, but I'm getting null
instead. Why?
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
contains items, it's not empty.