How to program an image chooser in Android? [duplicate]
I would like to program a image picker which should choose an image from the library. Is it possible to do this in a smooth way with the Android sdk? I'm pretty new to Android programming.
You should check Image-Gallery.
There are a few options: The simplest: If you want to have a strip of images, just add them all to a linear layout with horizontal orientation, and add the linear layout to HorizontalScrollView. Cons: It would not let you stop on an image.
My favourite, the more advanced one: As suggested above: Gallery. The gallery requires an adapter to fetch view at position n. It goes like this: You create an object that extends BaseAdapter and it creates views from images
myView = new ImageView();
myView.setImageDrawable( new BitmapDrawable.createFromPath("<path>") )
Another, more advanced way: There is that ImageSwitcher. It displays a gallery plus an image. See This page I have found when I encountered the same problem
Two important tips:
- Don't try to hack widgets implementing them manually. The performance might be bad.
- It's very recommended reading carefully about interfaces like Gallery. They offer lots of goodies and even more than that if you extend them.
Thanks
M.
精彩评论