增加活动 SlideView 的按钮

Button That increment active SlideView

我需要实现一个按钮来为每个幻灯片视图分别递增 0 值,但不知道如何实现

这是幻灯片视图 Slide 1

slide 2

这里是滑块视图的 java 代码

public class SliderAdapter extends PagerAdapter {
Context context;
LayoutInflater layoutInflater;
public SliderAdapter(Context context){
    this.context = context;
}

//Arrays
public int[] slide_images = {
        R.drawable.ic_armcircle,
        R.drawable.ic_ropejump,
        R.drawable.ic_jumpingjack,
        R.drawable.ic_burpee,
        R.drawable.ic_squat
};
public String[] slide_headings = {
        "ArmCircle",
        "RopeJump",
        "JumpingJack",
        "Burpee",
        "Squat"
};
@Override
public int getCount() {
    return slide_headings.length;
}

@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
    return view == (RelativeLayout) object;
}

@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    layoutInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
    View view =layoutInflater.inflate(R.layout.slide_layout, container, false);

    ImageView slideImageView = (ImageView) view.findViewById(R.id.HareketResmi);
    TextView slideHeading = (TextView) view.findViewById(R.id.HareketAdi);

    slideImageView.setImageResource((slide_images[position]));
    slideHeading.setText(slide_headings[position]);

    container.addView(view);

    return view;
}

@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
    container.removeView((RelativeLayout)object);
}

}

这是滑块的代码

public class Slider extends AppCompatActivity {
private ViewPager mSlideViewPager;
private LinearLayout mDotLayout;
private TextView[] mDots;
private SliderAdapter sliderAdapter;
//Tıkladıkca Artan Sayı
private int HareketSayaci = 0;
Button Saydir;
TextView Sayi;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_slider);

    mSlideViewPager = (ViewPager) findViewById(R.id.slideViewPager);
    mDotLayout = (LinearLayout) findViewById(R.id.dotsLayout);

    sliderAdapter = new SliderAdapter(this);

    mSlideViewPager.setAdapter((sliderAdapter));

    addDotsIndicator();

    //Tıkladıkca Artan Sayı
    Saydir = (Button) findViewById(R.id.Saydir);
    Sayi = (TextView) findViewById(R.id.TekrarSayisi);

    Saydir.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            HareketSayaci ++;
            Sayi.setText(Integer.toString(HareketSayaci));
        }
    });
}
public void addDotsIndicator(){

    mDots = new TextView[3];

    for(int i = 0; i < mDots.length; i++){
        mDots[i] = new TextView(this);
        mDots[i].setText(Html.fromHtml("&#8226;"));
        mDots[i].setTextSize(35);
        mDots[i].setTextColor(getResources().getColor(R.color.colorPrimaryDark));

        mDotLayout.addView(mDots[i]);
    }

}

}

我不知道是否需要分离计数器TextView,我该如何,

但这些都是头脑模糊的问题

真正的问题是

i need to code a button that increments the TextView Value when clicked

我没有正确理解你要面对的问题,但根据我对你问题的理解

您必须在 viewpager 更改时实现您的逻辑

viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageSelected(int position) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

也可以参考imageslider的这些例子

https://www.androhub.com/android-image-slider-using-viewpager/

https://www.sanktips.com/2017/10/01/how-to-add-dots-indicator-to-image-slider-with-viewpager-in-android-studio/