views:

455

answers:

1

Hi, I am new to android, I have learned how to display drawable pic in gallery, and display a url pic use ImageView. Now I dont know how to display online pictures in gallery. Should I use listview or not? In addtion, I want to know how to get pictures urls from flickrs with given userid

A: 

Do you mean like a photo gallery? is that what your app is supposed to do? Then, yes you could use a ListActivity/ListView. However i do not know if this will provide you with exactly the effect you want. A list view would load ALL of the pictures before the UI could be displayed and you would view them by scrolling. typically a photo viewer shows pictures full screen and switches with either a button or a swipe (gesture).

To get the latter effect, your app could display an ImageView with the first pic while it loads the next pic, and then switch to a new ImageView when the user clicks a button or swipes. this will prevent your app from eating up resources and will give you an interface that people are more used to.

as for flickr, you will have to ask someone else (you should separate these into two separate questions because they are so different)

mtmurdock
yeah, like a photo gallery. In android gallery demo, we load some pics from drawable folder, but I want use some online pictures instead of local pics.in gallery demo: Gallery g = (Gallery) findViewById(R.id.gallery); g.setAdapter(new ImageAdapter(this));public class ImageAdapter extends BaseAdapter { private Integer[] mImageIds = { R.drawable.sample_1,R.drawable.sample_2, R.drawable.sample_3}}
bitma
And in the web picture file: imView = (ImageView) findViewById(R.id.imview); imView.setImageBitmap(getRemoteImage(imageUrl)); public Bitmap getRemoteImage(String imageUrl) { try { URL aURL = new URL(imageUrl); final URLConnection conn = aURL.openConnection(); conn.connect(); final BufferedInputStream bis = new BufferedInputStream(conn.getInputStream()); final Bitmap bm = BitmapFactory.decodeStream(bis); bis.close(); return bm; }If I want to list some online pics in gallery, I have to use ListView or ListActivity?
bitma
well if all you want is a list of the pictures, then you can use either ListView or ListActivity (they are essentially the same, they are just implemented differently). If you want to display the online pics, you can either download them to a folder and then display them like you would local files, or you can change your ImageAdapter class to pull its images off flickr.
mtmurdock