Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

viewpager setonpagechangelistener deprecated

Today I'm trying to set ViewPager.setOnPageChangeListener and I've found out that it's deprecated.

like image 219
Jaydipsinh Zala Avatar asked Jun 16 '15 12:06

Jaydipsinh Zala


2 Answers

ViewPager.setOnPageChangeListener is deprecated now. Need to use ViewPager.addOnPageChangeListener instead.

for example,

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) {          }     }); 

You can find this Here.

like image 185
Jaydipsinh Zala Avatar answered Oct 12 '22 02:10

Jaydipsinh Zala


this worked for me:

viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener(){      @Override     public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {                conterchange.setText(""+(1+position));     }      @Override     public void onPageSelected(int position) {     }      @Override     public void onPageScrollStateChanged(int state) {     } }); 
like image 43
kinsley kajiva Avatar answered Oct 12 '22 03:10

kinsley kajiva