Domanda

I am using viewpagerindicator as part of my android application. getPageTitle of fragmentAdapter is getting called too many number of times on every slide of a page. I verified it with sample application provided as part of viewpagerindicator.

Sample application provied as part of viewpagerindicator has just 4 fragments/pages. But after every slide, getPageTitle is getting called almost 10 to 15 times for each position. Logger statement is attached with output.

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
È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top