JakeWharton/Android-ViewPagerIndicator — Issue #63: Divide by zero exception and fragments not showing
Author: Tywholland
Created: 2012-02-26 21:59:45+00:00
State: open

Some info on my project:
-Using ActionBarSherlock 4.0 RC1
-Target Android version is 4.0.3
-Using latest ViewPagerIndicator

I'm getting the following error when swiping on the title page indicator bar:
02-26 13:49:53.117: E/AndroidRuntime(26049): FATAL EXCEPTION: main
02-26 13:49:53.117: E/AndroidRuntime(26049): java.lang.ArithmeticException: divide by zero
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.support.v4.view.ViewPager.pageScrolled(ViewPager.java:1181)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.support.v4.view.ViewPager.fakeDragBy(ViewPager.java:1727)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at com.viewpagerindicator.TitlePageIndicator.onTouchEvent(TitlePageIndicator.java:503)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.View.dispatchTouchEvent(View.java:5486)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1959)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1728)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1892)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1371)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1840)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.View.dispatchPointerEvent(View.java:5662)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2863)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.os.Handler.dispatchMessage(Handler.java:99)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.os.Looper.loop(Looper.java:137)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at android.app.ActivityThread.main(ActivityThread.java:4340)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at java.lang.reflect.Method.invokeNative(Native Method)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at java.lang.reflect.Method.invoke(Method.java:511)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-26 13:49:53.117: E/AndroidRuntime(26049):	at dalvik.system.NativeStart.main(Native Method)

Another very strange problem I'm having is that when using the TitlePageIndicator of ViewPagerIndicator, my FragmentActivity that contains 3 fragments stops displaying the fragments. The fragments are all created and their OnCreateView is called, but they don't show up on the screen and I am unable to swipe between fragments. When I comment out the TitlePageIndicator code everything works perfectly. Here are some images to show what is happening:
With TitlePageIndicator:
http://imgur.com/RJaI9
Without TitlePageIndicator:
http://imgur.com/bboSd

My entire project is located [here](https://github.com/Tywholland/KitchenSync/tree/master/KitchenSync) and all of my problems are occurring in the grocerylist package of the project.

It seems to me like this should be because of a simple error on my part, but I've looked at all of the samples and instructions and it seems like I'm doing everything correctly.