I have an arraylist of images that is displayed in a ViewPager, so far so good, it's showing the whole arraylist normally.
But how do I get the ViewPager that is in focus? In other words, to get the right position of the arraylist being viewed by the ViewPager
private class ImagePagerAdapter extends PagerAdapter {
private ArrayList<Galeria> images;
private LayoutInflater inflater;
ImagePagerAdapter(ArrayList<Galeria> images) {
this.images = images;
inflater = getLayoutInflater();
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public int getCount() {
return images.size();
}
@Override
public Object instantiateItem(ViewGroup view, final int position) {
View imageLayout = inflater.inflate(R.layout.item_pager_image, view, false);
assert imageLayout != null;
ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);
final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
Log.i("POSITION",""+position);
... o resto do código não importa