调用notifyDataSetChanged()时出现Viewpager错误

时间:2016-12-15 06:13:47

标签: android android-fragments android-viewpager android-adapter

我使用viewpager显示大约20个片段但是在某些设备中,每当我为PagerAdapter调用notifydatasetchanged()时,我都会收到此错误

Exception java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Handler   android.support.v4.app.FragmentHostCallback.d()' on a null object reference
ba.b (SourceFile:1634)
android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss (SourceFile:679)
android.support.v4.app.FragmentStatePagerAdapter.finishUpdate (SourceFile:166)
android.support.v4.view.ViewPager.b (SourceFile:1098)
android.support.v4.view.ViewPager$c.onChanged (SourceFile:3117)
android.support.v4.view.PagerAdapter.notifyDataSetChanged (SourceFile:284)
co.sajan.vaarthakal.MainActivity.c (SourceFile:573)
co.sajan.vaarthakal.MainActivity.b (SourceFile:90)
co.sajan.vaarthakal.MainActivity$5.onDataChange (SourceFile:350)
com.google.android.gms.internal.zzbmz.zza ()
com.google.android.gms.internal.zzbnz.zzYj ()
com.google.android.gms.internal.zzboc$1.run ()
android.os.Handler.handleCallback (Handler.java:739)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:152)
android.app.ActivityThread.main (ActivityThread.java:5507)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)

可能是什么问题?

0 个答案:

没有答案