开发者

Displaying downloaded image in an imageView

Hi :) I'm trying to write an android application that downloads a bunch of images and afterwads disp开发者_StackOverflow中文版lays them in a gallery. I managed to download the images (i did download them do the data/data/project directory - not sure if that's right) but now i can't access them (i tried using the setImageURI method of the imageView to display the image after I've created an Uri instance via Uri.Builder().appendPath("data/data/project/file.jpg").build() but it was to no avail). I'm new to android developing so any help will be greatly appreciated. Thanks!


I started writing up an example, but decided that it was a waste of time since the net is littered with better examples then I could create.

At a high level, you'll need to do this:

  1. Get 1..n File objects
  2. Load Bitmaps from these objects using BitmapFactory
  3. Load these decoded bitmaps into a ImageView

The typical mechanism for viewing a set of resources like this is the Adapter pattern. As I mentioned, there is a good example here which also encompasses the use of AsyncTask and some other patterns typical of Android programming which you should become familiar with. Review that and see if you have further questions.


Try:

Uri uri = Uri.parse("file:///data/data/project/file.jpg");
image.setImageURI(uri);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜