2016-07-01 90 views
0

當調用notifyDataSetChange時,ViewPager拋出NullPointerException。當調用notifyDataSetChange時,ViewPager拋出NullPointerException

我覺得這是在支持庫中的錯誤監守我的適配器不爲空

堆棧跟蹤:

06-30 20:16:13.160 1578-1578/com.umeugwaDabeluchi.Ume E/AndroidRuntime: FATAL EXCEPTION: main 
Process: com.umeugwaDabeluchi.Ume, PID: 1578 
java.lang.NullPointerException 
    at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1623) 
    at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:637) 
    at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166) 
    at android.support.v4.view.ViewPager.populate(ViewPager.java:1235) 
    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:666) 
    at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:628) 
    at android.support.v4.view.ViewPager.dataSetChanged(ViewPager.java:1077) 
    at android.support.v4.view.ViewPager$PagerObserver.onChanged(ViewPager.java:3060) 
    at android.support.v4.view.PagerAdapter.notifyDataSetChanged(PagerAdapter.java:284) 
    at com.umeugwaDabeluchi.Ume.Fragments.EditFile.OnFileReady(EditFile.java:62) 
    at com.umeugwaDabeluchi.Ume.Utility.DataManager$2.run(DataManager.java:204) 
    at android.os.Handler.handleCallback(Handler.java:733) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:146) 
    at android.app.ActivityThread.main(ActivityThread.java:5635) 
    at java.lang.reflect.Method.invokeNative(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:515) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107) 
    at dalvik.system.NativeStart.main(Native Method) 
+2

難以幫助您在沒有[mcve]的情況下回答此問題。請至少顯示EditFile.java的第62行 –

回答

0
@Override 
public void OnFileReady() { 
    adapter.notifyDataSetChanged();//throws nullPointer Exception 
    Log.i(TAG, "EditFile OnFileReady: "); 
} 

@Override 
public void OnDataRemoved(int pos) { 
    adapter.notifyDataSetChanged();//throws nullPointer Exception 
    Log.i(TAG, "OnDataRemoved: " + "Page removed"); 
} 
相關問題