There is a CardView which is placed in ResyclerView, which is placed in the ViewPager. Spinner is built into the ToolBar. When you click on an element in Spinner, some variables change, and according to these changes you need to refresh the page in ViewPager. As far as I understand, the pages are updated after 1 from the current one in two directions (there are 3 items in the upload). How to forcibly refresh the page without resorting to crutches as in the code, but it does what it needs:
spinner_nav.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 1) { CalendarInfo.cngLast(); } else { CalendarInfo.cngFirst(); } int current = mViewPager.getCurrentItem(); mViewPager.setCurrentItem(current - 2, false); mViewPager.setCurrentItem(current + 1, false); mViewPager.setCurrentItem(current - 1, false); mViewPager.setCurrentItem(current + 2, false); mViewPager.setCurrentItem(current, false); }
Another problem with Spinner is that when the application is started, the code above is executed, although it should, in fact, when the selected item is changed.
Emulator screenshot http://data3.floomby.com/files/share/13_8_2016/15/zB19ew2WvktFjVaEh5ZQ.jpg