QuickFragmentPageAdapter
public class QuickFragmentPageAdapter<T extends Fragment> extends FragmentStatePagerAdapter {
private List<T> list;
public QuickFragmentPageAdapter(FragmentManager fm, List<T> list) {
super(fm);
this.list = list;
}
@Override
public Fragment getItem(int position) {
return list.get(position);
}
@Override
public int getCount() {
return list.size();
}
}
QuickPageAdapter
public class QuickPageAdapter<T extends View> extends PagerAdapter {
private List<T> list;
public QuickPageAdapter(List<T> list) {
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return view == object;
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
container.addView(list.get(position));
return list.get(position);
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView(list.get(position));
}
}