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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -