java.io.IOException:是Android目录

时间:2011-12-27 06:38:38

标签: android android-listview

我正在尝试将自定义列表视图中的可绘制文件夹中的图像插入ImageView。但是当我设置满足条件的图像时,它会从getView发出以下警告。

    12-27 11:56:56.356: DEBUG/skia(341): ---- read threw an exception
    12-27 11:56:56.366: WARN/System.err(341): java.io.IOException: Is a directory
12-27 11:56:56.366: WARN/System.err(341):     at org.apache.harmony.luni.platform.OSFileSystem.read(Native Method)
12-27 11:56:56.366: WARN/System.err(341):     at dalvik.system.BlockGuard$WrappedFileSystem.read(BlockGuard.java:165)
12-27 11:56:56.366: WARN/System.err(341):     at java.io.FileInputStream.read(FileInputStream.java:290)
12-27 11:56:56.366: WARN/System.err(341):     at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:166)
12-27 11:56:56.366: WARN/System.err(341):     at java.io.BufferedInputStream.read(BufferedInputStream.java:324)
12-27 11:56:56.366: WARN/System.err(341):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
12-27 11:56:56.366: WARN/System.err(341):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:470)
12-27 11:56:56.378: WARN/System.err(341):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:284)
12-27 11:56:56.378: WARN/System.err(341):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:309)
12-27 11:56:56.378: WARN/System.err(341):     at android.graphics.drawable.Drawable.createFromPath(Drawable.java:800)
12-27 11:56:56.378: WARN/System.err(341):     at android.widget.ImageView.resolveUri(ImageView.java:528)
12-27 11:56:56.378: WARN/System.err(341):     at android.widget.ImageView.setImageURI(ImageView.java:305)
12-27 11:56:56.378: WARN/System.err(341):     at android.widget.SimpleAdapter.setViewImage(SimpleAdapter.java:264)
12-27 11:56:56.378: WARN/System.err(341):     at android.widget.SimpleAdapter.bindView(SimpleAdapter.java:192)
12-27 11:56:56.378: WARN/System.err(341):     at android.widget.SimpleAdapter.createViewFromResource(SimpleAdapter.java:126)
12-27 11:56:56.378: WARN/System.err(341):     at android.widget.SimpleAdapter.getView(SimpleAdapter.java:114)
12-27 11:56:56.378: WARN/System.err(341):     at com.presentation.activity.ShowListActivity$CustomAdapter.getView(ShowListActivity.java:229)
12-27 11:56:56.378: WARN/System.err(341):     at android.widget.AbsListView.obtainView(AbsListView.java:1430)
12-27 11:56:56.386: WARN/System.err(341):     at android.widget.ListView.makeAndAddView(ListView.java:1745)
12-27 11:56:56.386: WARN/System.err(341):     at android.widget.ListView.fillDown(ListView.java:670)
12-27 11:56:56.386: WARN/System.err(341):     at android.widget.ListView.fillFromTop(ListView.java:727)
12-27 11:56:56.386: WARN/System.err(341):     at android.widget.ListView.layoutChildren(ListView.java:1598)
12-27 11:56:56.386: WARN/System.err(341):     at android.widget.AbsListView.onLayout(AbsListView.java:1260)
12-27 11:56:56.386: WARN/System.err(341):     at android.view.View.layout(View.java:7175)
12-27 11:56:56.386: WARN/System.err(341):     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
12-27 11:56:56.386: WARN/System.err(341):     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
12-27 11:56:56.386: WARN/System.err(341):     at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
12-27 11:56:56.396: WARN/System.err(341):     at android.view.View.layout(View.java:7175)
12-27 11:56:56.396: WARN/System.err(341):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-27 11:56:56.396: WARN/System.err(341):     at android.view.View.layout(View.java:7175)
12-27 11:56:56.396: WARN/System.err(341):     at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
12-27 11:56:56.396: WARN/System.err(341):     at android.view.View.layout(View.java:7175)
12-27 11:56:56.396: WARN/System.err(341):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1140)
12-27 11:56:56.396: WARN/System.err(341):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
12-27 11:56:56.396: WARN/System.err(341):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-27 11:56:56.396: WARN/System.err(341):     at android.os.Looper.loop(Looper.java:123)
12-27 11:56:56.396: WARN/System.err(341):     at android.app.ActivityThread.main(ActivityThread.java:3683)
12-27 11:56:56.396: WARN/System.err(341):     at java.lang.reflect.Method.invokeNative(Native Method)
12-27 11:56:56.396: WARN/System.err(341):     at java.lang.reflect.Method.invoke(Method.java:507)
12-27 11:56:56.396: WARN/System.err(341):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-27 11:56:56.406: WARN/System.err(341):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-27 11:56:56.406: WARN/System.err(341):     at dalvik.system.NativeStart.main(Native Method)
12-27 11:56:56.466: WARN/System.err(341):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)


    12-27 11:56:56.406: WARN/System.err(341):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-27 11:56:56.466: DEBUG/skia(341): ---- read threw an exception
12-27 11:56:56.466: DEBUG/skia(341): --- SkImageDecoder::Factory returned null
12-27 11:56:56.466: INFO/System.out(341): resolveUri failed on bad bitmap uri: 

我正在使用自定义适配器扩展SimpleAdapter并根据条件放置文本和图标。

我的客户适配器看起来像......

serviceAdapter = new CustomAdapter(this, serviceList, R.layout.list_row,
                new String[] { "name", "duration","reason", "remark", "img1", "img2", "img3",
                        "img" }, new int[] { R.id.servicename, R.id.duration,R.id.reason, R.id.remark,
                        R.id.statusImg1, R.id.statusImg2, R.id.statusImg3, R.id.isExpandable });

我正在从HashMap中添加相应的值...

HashMap<String, Object> rowValue = new HashMap<String, Object>();

使用图像。 rowValue.put("img2", R.drawable.img);

它没有抛出任何错误,但却大大减慢了应用程序的速度。任何人都可以让我知道问题可能是什么......

2 个答案:

答案 0 :(得分:2)

检查图像路径中的图像名称。问题可能出在图像路径中。我确信指向任何不提交的目录。

答案 1 :(得分:0)

可能问题是:图像文件路径指向文件夹而非文件