且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ViewPager + 片段中的适配器 =>延迟刷卡

更新时间:2023-11-18 12:25:52

我的问题是,是否可以在刷卡后设置适配器Pager 什么时候空闲?

My Question is, wether it is possible to set the Adapter after swiping when it Pager is idle?

OnPageChangeListener 您可以在 ViewPager 上设置以监控滑动手势.然后,您可以使用 onPageSelected()(或 onPageScrollStateChanged() 来监视当前状态)方法在选择新页面时获得通知并从该方法开始数据加载.

There is the OnPageChangeListener that you could set on the ViewPager to monitor the swipe gestures. You could then use the onPageSelected()(or the onPageScrollStateChanged() to monitor the current state) method to get notified when a new page has been selected and start from that method the loading of data.

另外,请确保 ListView 对延迟负责,而不是代码的其他部分.

Also, make sure the ListView are responsible for the lag and not some other part of your code.