ViewPager单击预加载页面上的按钮

时间:2018-10-09 12:39:51

标签: android android-viewpager

    public class MyViewPagerAdapter extends PagerAdapter implements View.OnClickListener{
            private LayoutInflater layoutInflater;

            btn_A_L2 = v.findViewById(R.id.option_A_L2);
    public Object instantiateItem(ViewGroup container, final int position) {
                layoutInflater = getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                assert layoutInflater != null;
                View v = layoutInflater.inflate(R.layout.lesson_picture_options, container, false);
                btn_A_L2.setText(words.get(rnd).learn_lang);
                btn_A_L2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        //clicked in another page
                    }
                });
                container.addView(v);
                return v;
            }

这是我的ViewPager适配器,我试图在每个页面中单击Buttons,但是在另一个预加载页面(如上一页或下一页)而非当前页面中单击了Button。有人可以帮我吗?

0 个答案:

没有答案