For the Android application I am currently creating I would like to have a simple image gallery. Ideally it would be a single line of images with a horizontal scroll bar (much like this: http://www.appszoom.com/android_applications/multimedia/3d-gallery_hbij.html although the 3D effect isn’t necessary).
I know that the Android API used to have the Gallery Class which would have been perfect, but now this has been deprecated. Now I have managed to create a simple gallery using LinearLayout and HorizontalScrollView as such
XML:
<HorizontalScrollView
android:id="@+id/hor_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/gallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
Aesthetically this is perfect; looking exactly how I want it to (I don’t see the significance of posting my code but I am more than happy to upon request). The problem with this lies in the functionality. It’s important that the user has the ability to select an image from the gallery list but this seems to be impossible using my current approach. I have read that a ViewPager could also be used but from my understanding it seems that this would also be impossible to select individual images from. GridView would be my next choice as one can implement the OnItemClickListener however surely this will pose a problem of dynamically adding columns when the user takes a photo.
So my question is simply: how do I go about achieving this functionality of selecting individual images?
As a final note: I am fairly new to Android programming but am highly proficient with Java.
In the end I considered using a
ListViewfor my image gallery as it being a subclass ofAdapterViewallows one to use thesetOnItemClickListener. The problem with this however is theListViewonly provides a vertical list and I needed a horizontal one. So after some digging I managed to find someone who had created aHorizontalListViewand it is perfect. You can find it here