I always see a crossed out line setOnTabSelectedListener for the following code
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
}
And the error shown is:
setOnTabSelectedListener is deprecated
However, the program seems to work just fine. May I know what's going on?