在扩展BaseAdapter的类中调用代码。
" allFavorite.get(位置).getImageDir()"会像这样给出和回复#34; http://abc-production.ch/_data/img/icon/20140812-111305-656.jpg"这似乎工作正常,但很快" imageLoader.loadImageSync"被称为崩溃。
private ImageLoaderConfiguration config;
private ImageLoader imageLoader;
config = new ImageLoaderConfiguration.Builder(activity).build();
ImageLoader.getInstance().init(config);
Bitmap bm = imageLoader.loadImageSync(allFavorite.get(position).getImageDir());
imageFavorite.setImageBitmap(bm);
这是LogCat崩溃时的日志:
11-20 15:15:17.777: W/dalvikvm(18979): threadid=1: thread exiting with uncaught exception (group=0x417a5d88)
11-20 15:15:17.777: E/AndroidRuntime(18979): FATAL EXCEPTION: main
11-20 15:15:17.777: E/AndroidRuntime(18979): Process: ch.digvis.abcproduction, PID: 18979
11-20 15:15:17.777: E/AndroidRuntime(18979): java.lang.NullPointerException
11-20 15:15:17.777: E/AndroidRuntime(18979): at ch.digvis.abcproduction.adapter.FavoriteListAdapter.getView(FavoriteListAdapter.java:71)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.AbsListView.obtainView(AbsListView.java:2255)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.ListView.makeAndAddView(ListView.java:1790)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.ListView.fillDown(ListView.java:691)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.ListView.fillFromTop(ListView.java:752)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.ListView.layoutChildren(ListView.java:1630)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.AbsListView.onLayout(AbsListView.java:2087)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.View.layout(View.java:14948)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.View.layout(View.java:14948)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.View.layout(View.java:14948)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:801)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.View.layout(View.java:14948)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.View.layout(View.java:14948)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 15:15:17.777: E/AndroidRuntime(18979): at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:374)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.View.layout(View.java:14948)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.View.layout(View.java:14948)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewGroup.layout(ViewGroup.java:4631)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5622)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.Choreographer.doFrame(Choreographer.java:544)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.os.Handler.handleCallback(Handler.java:733)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.os.Handler.dispatchMessage(Handler.java:95)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.os.Looper.loop(Looper.java:212)
11-20 15:15:17.777: E/AndroidRuntime(18979): at android.app.ActivityThread.main(ActivityThread.java:5135)
11-20 15:15:17.777: E/AndroidRuntime(18979): at java.lang.reflect.Method.invokeNative(Native Method)
11-20 15:15:17.777: E/AndroidRuntime(18979): at java.lang.reflect.Method.invoke(Method.java:515)
11-20 15:15:17.777: E/AndroidRuntime(18979): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
11-20 15:15:17.777: E/AndroidRuntime(18979): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
11-20 15:15:17.777: E/AndroidRuntime(18979): at dalvik.system.NativeStart.main(Native Method)`
答案 0 :(得分:0)
我无法添加评论,所以我在这里试试,
getView方法中您的FavoriteListAdapter的第71行是什么?
答案 1 :(得分:0)
我认为你的allFavorite.get(position).getImageDir())
返回null,这是NullPointerException的问题,请检查你是否得到了正确的路径。