在对话框上显示图像时出错

时间:2016-05-11 13:37:59

标签: android dialog imageview android-volley networkimageview

解决

我尝试在对话框中显示图像。 当我点击列表视图中的项目时,对话框将显示当我点击时的详细信息项目。 但是当我尝试显示图像时我得到了错误,这里的日志说:

com.felix.tirtagympool.AbdominalFragment.onItemClick(AbdominalFragment.java:164 = thumbnail.setImageUrl(exerciseList.get(position).getGambar1(),imageLoader)

    05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime: FATAL EXCEPTION: main
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime: Process: com.felix.tirtagympool, PID: 13073
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime: java.lang.NullPointerException
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at com.felix.tirtagympool.AbdominalFragment.onItemClick(AbdominalFragment.java:164)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at android.widget.AdapterView.performItemClick(AdapterView.java:299)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2904)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at android.widget.AbsListView$3.run(AbsListView.java:3638)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:733)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:136)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5017)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
05-11 21:57:19.958 13073-13073/com.felix.tirtagympool E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
05-11 21:57:21.298 13073-13073/com.felix.tirtagympool I/Process: Sending signal. PID: 13073 SIG: 9

这里是我的abdominalfragment.java 更改此代码

ImageLoader imageLoader = AppController.getInstance().getImageLoader();
NetworkImageView thumbnail = (NetworkImageView)convertView.findViewById(R.id.gambar11);
// thumbnail image
thumbnail.setImageUrl(exerciseList.get(position).getGambar1(), imageLoader);

1 个答案:

答案 0 :(得分:0)

赞这个

ImageLoader imageLoader = AppController.getInstance().getImageLoader();
NetworkImageView thumbnail1 = (NetworkImageView ) dialog.findViewById(R.id.gambar11);
thumbnail1.setImageUrl(exerciseList.get(position).getGambar1(), imageLoader);