android - Get RecyclerView last visible item -
findlastvisibleitemposition
returns -1 following sequence:
onviewcreated() { recyclerview.setadapter(adapter = new adapter()); adapter.updatecontent(list<content>); // call notifyitemrangechanged post(new runnable() { run() { layoutmanager.getlastvisibleitem(); // == -1 (using runnable or not) } } }
it seems children views not ready yet. using tree observer on recyclerview
seems solve problem, best approach last visible item after setting content adapter right after creation?
Comments
Post a Comment