我在位图库中遇到问题,如果我刷新我的图库活动错误。 我从儿童活动回到画廊错误..
logcat的
06-05 03:22:24.848 2366-2366/com.skripsi.test E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.skripsi.test, PID: 2366
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.skripsi.test/com.skripsi.test.Detail_bengkel}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2318)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5268)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.skripsi.test.GalleryAdapter.loadBitmap(GalleryAdapter.java:63)
at com.skripsi.test.Detail_bengkel.onCreate(Detail_bengkel.java:138)
at android.app.Activity.performCreate(Activity.java:5403)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5268)
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:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
galleryadapter.java:63
String url = getItem(position).toString();
detail_bengkel.java:138
imageViewURL.setImageBitmap(galleryAdapter.loadBitmap(3));
帮帮我......
抱歉英语不好..
谢谢你..
答案 0 :(得分:1)
问题在于您使用params getItems
致电3
,而null
返回if (galleryAdapter.getCount() > 0){
imageViewURL.setImageBitmap(galleryAdapter.loadBitmap(galleryAdapter.getCount() - 1));
}
,因为该位置没有任何内容。您需要使用有效索引访问适配器中的项目。
例如,如果要在ImageView中显示适配器中的最后一个图像。
var a = 'toto titi (should be removed) 5'.replace(/\(.*\)|\[.*\]|[^a-zA-Z0-9 ]|tata|tutu|tyty/gi, '!$!');
var b = 'toto titi (should be removed) 5'.replace(new RegExp('\(.*\)|\[.*\]|[^a-zA-Z0-9 ]|tata|tutu|tyty', 'gi'), '!$!');
console.log(a);
console.log(b);