将变量从ViewPager传递给Clicklistener

时间:2018-06-28 08:42:39

标签: java android android-viewpager

如何获取ionic cordova build --aot --minifycss --minifyjs --optimize-js ViewPager.OnPageChangeListener()的实际位置:

OnClickListener

这就是@Override public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { btnDL.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // I need the "int posistion" here } }); }

OnPageChangeListener

谢谢!

1 个答案:

答案 0 :(得分:1)

使用此

@Override
   public View onCreateView(LayoutInflater inflater, final ViewGroup
   container,
                         Bundle savedInstanceState) {

    btnDL.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            int pos = viewPager.getCurrentItem();
    } });