i have slider with view pager. and i have adapter extends PagerAdapter
.
the problem is that: i don't want may slider swiping with finger. it means, i want it works just automatically.
public class TopFoodSlider_adapter extends PagerAdapter {
private Context context;
private List<top_food_slider> slideList;
private int custom_postion = 0;
private int t =0;
public TopFoodSlider_adapter(Context context, List<top_food_slider> slideList) {
this.context = context;
this.slideList = slideList;
}
@Override
public int getCount() {
return Integer.MAX_VALUE;
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return (view == object);
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position)
{
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(R.layout.top_food_slider_item,container,false);
top_food_slider slid = slideList.get(custom_postion);
custom_postion++;
int img=slid.getImg_src();
ImageView imageView=view.findViewById(R.id.imageView);
imageView.setImageResource(img);
container.addView(view);
if (custom_postion>=slideList.size())
custom_postion = 0;
return view;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView((LinearLayout)object);
}
}