Я создал viewPager, теперь я хочу знать, как я могу установить номера страниц в viewPager?И как я могу перейти к ViewPager номер 12, когда я нажимаю на 12 номер на странице индекса.Ниже есть изображение.
![enter image description here](https://i.stack.imgur.com/IWsyn.png)
Вот мой код
public class SwipeAdapter extends PagerAdapter {
private Context cx;
int[] image=new int[3];
int a=1;
SwipeAdapter(Context cx){
this.cx=cx;
for(int i=0;i<3;i++) {
a = i + 1;
image[i]=cx.getResources().getIdentifier("image"+a,"drawable", cx.getPackageName());
}
}
@Override
public int getCount() {
return image.length;
}
@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
return (view==object);
}
@SuppressLint("SetTextI18n")
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
LayoutInflater layoutInflater = (LayoutInflater) cx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
assert layoutInflater != null;
View view= layoutInflater.inflate(R.layout.fragment_page,container,false);
ImageView imageView= view.findViewById(R.id.imageView);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.setImageResource(image[position]);
container.addView(view);
return view;
}
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
container.removeView((RelativeLayout) object);
}