ViewPager addOnPageChangeListener not working on same tabClick

前端 未结 2 478
一整个雨季
一整个雨季 2021-01-06 06:56

I have a ViewPager with addOnPageChangeListener. ViewPager has 3 tabviews (tab1, tab2, tab3). When a user clicks tab2, it loads some d

2条回答
  •  余生分开走
    2021-01-06 07:29

    It sounds like your onPageSelected callback is not being called because the page isn't actually changing. I think if you write a custom subclass of TabLayout.ViewPagerOnTabSelectedListener, you can use the onTabReselected callback to trigger your refresh even those the selected page index hasn't changed.

    You should be able to install your custom OnTabSelectedListener using TabLayout::setOnTabSelectedListener after you call setupWithViewPager.

提交回复
热议问题