实现ImageSwitcher功能| FileNotFoundException异常

时间:2014-02-19 02:27:46

标签: java universal-image-loader

我正在尝试使用Android-Universal-Image-Loader实现ImageSwitcher功能, 以下是代码,

public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);
            Uri uri = Uri.parse(imageUrls[position]);

            System.out.println("URI=" + uri);
         InputStream inputStream;
        try {
            **inputStream = getContentResolver().openInputStream(uri);**
            Bitmap bm= BitmapFactory.decodeStream(inputStream);

            i.setImageBitmap(bm);
            i.setAdjustViewBounds(true);

但是,我得到了FileNotFoundException

inputStream = getContentResolver().openInputStream(uri);

但是当我尝试直接从Web浏览器访问URI时,我看到了图像。 Image URI以这种方式设置:

public static final String[] IMAGES = new String[] {

    "http://image.donga.com/mlbpark/fileUpload/201401/52dde15113c53b01da3b.jpg",
    "https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg",
    etc...

知道我哪里错了吗?

0 个答案:

没有答案