I have created a custom class extending PagerAdapter
that represents my adapter to a ViewPager
in which I slide through Views
(not Fragments).
What my problem really is, is that I don't know how to get the current View that I have add to the adapter earlier so that I can follow a certain procedure with it.
The PagerAdapter
only provides instantiateItem(ViewGroup container, int position)
method that returns an Object
and with my implementation, it returns a View
.
Is this the right method to call to get the View
in the current position? And if Yes, what I pass as a container
argument?
Thank you in advance!
References:
SequenceAdapter.java
public class SequenceAdapter extends PagerAdapter {
private List<View> mList;
public SequenceAdapter(){
this.mList = new ArrayList<>();
}
public void add(View viewGroup){
mList.add(mList.size(), viewGroup);
notifyDataSetChanged();
}
@Override
public int getCount() {
return mList.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = mList.get(position);
container.addView(view, position);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public CharSequence getPageTitle(int position) {
return null;
}