android viewpagerindicator调用getPageTitle()的次数太多了

时间:2013-07-30 08:15:44

标签: android viewpagerindicator

我使用viewpagerindicator作为我的Android应用程序的一部分。 fragmentAdapter的getPageTitle在页面的每个幻灯片上被调用的次数太多。我使用作为viewpagerindicator的一部分提供的示例应用程序验证了它。

作为viewpagerindicator的一部分提供的示例应用程序只有4个片段/页面。但是在每张幻灯片之后,每个位置的getPageTitle被调用大约10到15次。记录器语句附带输出。

有什么方法可以避免这种情况吗?

 @Override
public CharSequence getPageTitle(int position) {
    Log.d("SAMPLE","Title Getting called for "+position);
  return TestFragmentAdapter.CONTENT[position % CONTENT.length];
} 


08-07 13:02:09.835: D/BatteryService(1501): update start
08-07 13:02:10.421: I/InputReader(1501): dispatchTouch::touch event's action is 0
08-07 13:02:10.421: I/InputDispatcher(1501): Delivering touch to current input target
08-07 13:02:10.421: D/PowerManagerService(1501): reactivateScreenLocksLocked mProxIgnoredBecauseScreenTurnedOff=false
08-07 13:02:10.421: I/PowerManagerService(1501): Ulight 1->3|0
08-07 13:02:10.437: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.437: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.445: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.445: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.445: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.445: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.445: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.445: D/SurfaceFlinger(1501): Layer[332660] [35] non-RGB565 reloads
08-07 13:02:10.460: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.460: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.460: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.460: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.460: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.460: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.460: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.476: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.476: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.476: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.484: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.484: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.484: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.484: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.500: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.500: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.500: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.500: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.500: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.500: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.500: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.515: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.515: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.515: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.515: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.515: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.515: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.539: I/InputReader(1501): dispatchTouch::touch event's action is 1
08-07 13:02:10.539: I/InputDispatcher(1501): Delivering touch to current input target
08-07 13:02:10.562: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.562: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.562: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.562: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.562: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.562: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.570: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.570: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.570: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.570: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.570: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.570: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.585: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.585: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.585: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.585: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.585: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.585: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.593: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.593: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.593: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.593: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.593: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.601: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.609: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.609: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.609: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.609: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.609: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.609: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.617: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.617: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.617: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.625: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.625: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.625: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.632: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.632: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.632: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.632: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.640: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.640: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.648: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.648: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.648: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.648: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.648: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.648: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.656: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.656: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.656: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.656: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.664: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.664: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.671: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.671: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.671: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.671: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.671: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.679: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.687: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.687: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.687: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.687: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.687: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.687: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.687: I/PowerManagerService(1501): Light Animator Finished curIntValue=143
08-07 13:02:10.695: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.695: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.695: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.695: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.695: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.695: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.703: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.703: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.703: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.703: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.710: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.710: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.718: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.718: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.718: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.718: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.718: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.718: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.726: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.726: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.726: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.726: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.726: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.726: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.734: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.734: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.734: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.734: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.742: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.742: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.765: D/SAMPLE(28147): Title Getting called for 0
08-07 13:02:10.765: D/SAMPLE(28147): Title Getting called for 1
08-07 13:02:10.773: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.773: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:10.773: D/SAMPLE(28147): Title Getting called for 2
08-07 13:02:10.773: D/SAMPLE(28147): Title Getting called for 3
08-07 13:02:11.421: D/wpa_supplicant(1637): CMD: DRIVER RSSI-APPROX
08-07 13:02:11.445: D/wpa_supplicant(1637): wpa_driver_priv_driver_cmd buf = xxxxxxxx len = 15, 15
08-07 13:02:11.445: D/wpa_supplicant(1637): CMD: DRIVER LINKSPEED
08-07 13:02:11.445: D/wpa_supplicant(1637): wpa_driver_priv_driver_cmd buf = xxxxxxxx len = 12, 12

1 个答案:

答案 0 :(得分:1)

它按照预期工作。适配器总是提前两页加载(因此它需要当前页面,上一页和下一页的标题)。如果您想避免这种情况,可以尝试在setOffscreenPageLimit(0)个实例上调用viewpager