示例来源:http: //developer.android.com/training/displaying-bitmaps/index.html
不知道为什么我根本无法运行该项目。
原木猫
09-06 13:14:13.664: E/AndroidRuntime(591): FATAL EXCEPTION: main
09-06 13:14:13.664: E/AndroidRuntime(591): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.bitmapfun/com.example.android.bitmapfun.ui.ImageGridActivity}: java.lang.NullPointerException
09-06 13:14:13.664: E/AndroidRuntime(591): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.app.ActivityThread.access$600(ActivityThread.java:122)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.os.Handler.dispatchMessage(Handler.java:99)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.os.Looper.loop(Looper.java:137)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.app.ActivityThread.main(ActivityThread.java:4340)
09-06 13:14:13.664: E/AndroidRuntime(591): at java.lang.reflect.Method.invokeNative(Native Method)
09-06 13:14:13.664: E/AndroidRuntime(591): at java.lang.reflect.Method.invoke(Method.java:511)
09-06 13:14:13.664: E/AndroidRuntime(591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-06 13:14:13.664: E/AndroidRuntime(591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-06 13:14:13.664: E/AndroidRuntime(591): at dalvik.system.NativeStart.main(Native Method)
09-06 13:14:13.664: E/AndroidRuntime(591): Caused by: java.lang.NullPointerException
09-06 13:14:13.664: E/AndroidRuntime(591): at com.example.android.bitmapfun.util.DiskLruCache.getDiskCacheDir(DiskLruCache.java:268)
09-06 13:14:13.664: E/AndroidRuntime(591): at com.example.android.bitmapfun.util.ImageCache.init(ImageCache.java:121)
09-06 13:14:13.664: E/AndroidRuntime(591): at com.example.android.bitmapfun.util.ImageCache.<init>(ImageCache.java:61)
09-06 13:14:13.664: E/AndroidRuntime(591): at com.example.android.bitmapfun.util.ImageCache.findOrCreateCache(ImageCache.java:107)
09-06 13:14:13.664: E/AndroidRuntime(591): at com.example.android.bitmapfun.ui.ImageGridFragment.onCreate(ImageGridFragment.java:96)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:834)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:505)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.app.Activity.performStart(Activity.java:4475)
09-06 13:14:13.664: E/AndroidRuntime(591): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1928)
09-06 13:14:13.664: E/AndroidRuntime(591): ... 11 more