0
android刪除或從圖庫中回收圖像?可能嗎?android刪除或從圖庫中回收圖像?可能嗎?
我該怎麼做? (g爲我的相冊查看)
我嘗試這樣做:
private void exit() {
g.setAdapter(null);
for (int i=0; i< imgadapter.images.size(); i++) {
if (imgadapter.images.get(i)!=null) {
imgadapter.images.get(i).recycle();
imgadapter.images.set(i, null);
}
}
imgadapter.images.clear();
System.gc();
}
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): java.lang.NullPointerException
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.widget.Gallery.makeAndAddView(Gallery.java:748)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.widget.Gallery.layout(Gallery.java:625)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.widget.Gallery.onLayout(Gallery.java:339)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.view.View.layout(View.java:7228)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.view.View.layout(View.java:7228)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.view.View.layout(View.java:7228)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.view.View.layout(View.java:7228)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.view.ViewRoot.performTraversals(ViewRoot.java:1145)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.os.Looper.loop(Looper.java:130)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at android.app.ActivityThread.main(ActivityThread.java:3687)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at java.lang.reflect.Method.invokeNative(Native Method)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at java.lang.reflect.Method.invoke(Method.java:507)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
08-05 09:09:19.671: ERROR/AndroidRuntime(1279): at dalvik.system.NativeStart.main(Native Method)
Android的Gallery類中的回收代碼已損壞。不知道他們是否已經修復了這個問題,但它仍然在eclair中被破解:http://code.google.com/p/android/issues/detail?id=3376 – satur9nine
看起來它在ICS中仍然存在 –