public void setSelectedItem(int position) { selectedItem = position; notifyDataSetChanged(); } }
@Override public void onPageSelected(int position) { imagesHorizontalList.smoothScrollToPosition(position); hAdapter.setSelectedItem(position); }
@Override protected void afterInflation() { mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); // get extra values imgPlaceHolderResId = getIntent().getIntExtra(Constants.IntentPassingParams.IMG_PLACEHOLDER, -1); spanCount = getIntent().getIntExtra(Constants.IntentPassingParams.COUNT, 2); adapter = new GridImagesAdapter(this, imageURLs, imgPlaceHolderResId); mRecyclerView.setLayoutManager(new GridLayoutManager(this, spanCount)); mRecyclerView.setAdapter(adapter); }
adapter = new ViewPagerAdapter(this, imageURLs, mToolbar, imagesHorizontalList); mViewPager.setAdapter(adapter); hAdapter = new HorizontalListAdapters(this, imageURLs, new OnImgClick() { @Override public void onClick(int pos) { imagesHorizontalList.setLayoutManager(mLayoutManager); imagesHorizontalList.setAdapter(hAdapter); hAdapter.notifyDataSetChanged(); hAdapter.setSelectedItem(currentPos); mViewPager.setCurrentItem(currentPos);