android - How to select first item in recyclerview -


suppose have selected position 3 in recyclerview when navigate previous page , come again want frist item of recyclerview selected

    int selectposition = 0;   if (selectedposition == position ) {             chckbox.setvisibility(view.visible);             chckbox.setchecked(true);             chckbox.setbackgroundresource(r.drawable.checkbox_selector);             chckbox.forcelayout();             layout.setbackgroundresource(r.drawable.selected_address_bg);          } else {             chckbox.setvisibility(view.visible);             chckbox.setchecked(false);             layout.setbackgroundresource(r.color.white);         } 

you can scroll first position following code: can replace layout manager

linearlayoutmanager layoutmanager = (linearlayoutmanager) mrecyclerview                     .getlayoutmanager();             layoutmanager.scrolltopositionwithoffset(0, 0); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -