I'm going to write a test task schedule for the university. There are 7 possible pairs per day. I think what component to choose for them.

I think you can choose RecyclerView for storage in it. Each pair has a time period when it lasts.

The question is : is there any interface for recyclerview, which, when loading a fragment, can scroll to a pair that goes at the right moment.

I think if there is no such possibility, you can just try to highlight the desired pair of color

    2 answers 2

    It is possible so if to use LinearLayoutManager

    LinearLayoutManager layoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(layoutManager); int indexOfItem = getCurrentIndex(); layoutManager.scrollToPositionWithOffset(indexOfItem , 0); 
    • Thanks, as I understood it it is necessary to do it in onActivityCreated in the fragment so? - danilshik
    • obviously need so - Komdosh

    The RecyclerView class has the scrollToPosition(position) method, which will move the list to the desired position and the smoothScrollToPosition(position) method, which will make this somewhat smoother.

    For example, move the list to the sixth item (the position count starts from 0)

     recyclerView.scrollToPosition(5); 
    • where should i use this method? Just as announced on onViewCreated? - danilshik
    • in the very place where you need to move the list to the desired position. Immediately after its execution will move. Where exactly this place is in your code is known only to you. - pavlofff