简体   繁体   English

android viewpagerindicator多次调用getPageTitle()

[英]android viewpagerindicator calling getPageTitle() too many times

I am using viewpagerindicator as part of my android application. 我正在使用viewpagerindicator作为我的android应用程序的一部分。 getPageTitle of fragmentAdapter is getting called too many number of times on every slide of a page. fragmentAdapter的getPageTitle在页面的每张幻灯片上被调用太多次。 I verified it with sample application provided as part of viewpagerindicator. 我使用viewpagerindicator提供的示例应用程序对其进行了验证。

Sample application provied as part of viewpagerindicator has just 4 fragments/pages. 作为viewpagerindicator的一部分提供的示例应用程序只有4个片段/页面。 But after every slide, getPageTitle is getting called almost 10 to 15 times for each position. 但是在每张幻灯片之后,每个位置的getPageTitle都会被调用近10到15次。 Logger statement is attached with output. Logger语句随输出附在一起。

Is there any way to avoid this? 有什么办法可以避免这种情况?

 @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

It works as it supposed . 它按预期工作。 The adapter load always two pages in advance (so it need the title for the current, previous and next page). 适配器始终总是提前两页加载(因此,它需要当前,上一页和下一页的标题)。 If you want to avoid this beahviour you can try calling setOffscreenPageLimit(0) on your viewpager instance 如果要避免这种行为,可以尝试在viewpager实例上调用setOffscreenPageLimit(0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM