Actions on gallery view android - android

i have two gallery views in my single UI screen or you may say activity, i want to have listener in such a way that on scroll of one gallery view the other should also scroll , i tried giving listener to one gallery and calling the other one gallery view into that ., but its working for me , pls can any one help me..
thanks in advance
Datta

You could try to find the position of one of the galleries with Gallery.setOnItemSelectedListener() and then update the other gallery with Gallery.setSelection().

I believe the Gallery view is missing a lot of functionality (or is broken) as compared to ListView or GridView. In this particular instance, you need a "setOnCenteredItemChangedListener" or something like that. However, the documentation does not show anything close to this.
One option would be to implement your own Gallery class using HorizontalScrollView.
Another (hacky) option would be to rely on your Gallery adapter to push the current position being fetched (which may NOT be the one displayed in the middle) and use that to guess the currently selected position.

You have to override the scroll event of your first gallery and inside this method you should call the onScroll event of your second gallery like this,
gallery_two.onScroll(MotionEvent e1,MotionEvent e2,x,y);

Related

ListView, Gallery or HorizontalScrollView?

Alright, I want to do something like a Gallery of images, scrolling from left to right. The user is going to register barrages, and he needs to take many picture of this barrage. I already know how to save the data, and how to show using listview with adapter, I did with listview thinking that I could change to horizontal somehow, but I searched and I can't. What should I use to do that? What I want is a gallery with the first photo being a plus to when you click it opens a new intent that take a picture and a description of the pic and save it, I know how to do that with listview, but it's not what I want. I saw that gallery view is deprecated, so I should use HorizontalListView?
Gallery is deprecated, yes. So maybe HorizontalListView.
But i think, that you can use fragments with animation
Use linearLayout that is placed in horizontalScrollView and on runtime Add pictures to that LinearLayout that has orientation set to horizontal. Best practise will be create your own class where you will have specified LayoutParams that you will apply to each ImageView generated on runtime , then you just need to add it to layout.
You can define method like addPictures(LinerLayout yourLayout,int amountOfPictures,Array pituresPaths) that will be loop which will create ImageViews for specified amount of Pictures and paths you can take from ArrayEditLike xoxol_89 mentioned you can use Fragments , advantege will be that FragmentAdapter dynamically recreates and destroys fragment objects so that solution with many pictures will be more memory resource efficient

How to create horizontal listview which is fix the count of item when display

I want to create a horizontal listview which contain many item, one item will contain a image. When user slide listview => the count of item will be fix when it display, example display only 3 or 4 image. How can I do that? Many thanks.
Edit:
I use this
to create a HorizontalList view, everything is ok but I don;t know how to make the Next and Previous button work! Any idea?
Instead of a horizontal ListView (which, as far as I know, isn't offered by the Android SDK) you can use a HorizontalScrollView. You can add the items like to any other kind of layout class.
It looks like what you are looking for is a Paginated Gallery. I have written one here.
Its still only a couple of days old but hopefully the included Activity code will get you off the ground.

Custom Adapter for Gallery View in Android

hi i want to split my gallery with 5 images in 2 rows.
Please let me know how to do this in android using Gallery View & custom adapter for Gallery view.
Is there any sample code available please share it, i have already checked the previous posts in this site.
Thanks
If you still need this and Pagination instead of scroll will work for you, you might look at: https://github.com/sfarooq/PaginatedGallery
I designed it using ViewPager so you can manipulate the adapter to send any kind of views you want including two row views.
If you must use scrolling galleries you could implement two separate gallery in a vertical orientation and send touch events from each to the other.

Android How to know if a Gallery is scrolling?

I have a gallery and when a image is selected, I want to start new thread (for loading other images). But I don't want to do it while the gallery is scrolling. How can I know the state of the gallery and if it is still scrolling?
I can't use "setCallbackDuringFling(false)" because I have a textview under the image that has to be updated during the scrolling...
Thanks!
Marc
I think you could have a go with setCallbackDuringFling method. From what I understand, if you set it to false, it shouldnt be possible to select an item while fling is being computed.
Use a Handler that is called from the onItemSelectedListener that updates the last time that an item was selected (every time the foremost item changes this listener is fired) and use a timeout value to determine when scrolling ended to determine if scrolling is still occurring.
However, I have the exact same thing in andAMP... I have a FrameLayout with a Gallery and 2 textviews to show the foremost selected Artist and Album... I use onItemSelectedListener to update those TextViews and it works fine. If you have the TextViews in a FrameLayout like me you have to use bringChildToFront to get them to show over the Gallery (add the Gallery last).
As far as Lazy Loading (which I am assuming that is what you are doing). There are a couple of great tutorials about how to do this.
http://ballardhack.wordpress.com/2010/04/05/loading-remote-images-in-a-listview-on-android/
http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html

OnClickListener and OnTouchListener

I have an 2 adapters extending BaseAdapater. The first Adapter (let's call it imageAdapter) loads an image base on an ID, the second adapter (pageAdapter) builds grids of images from the first adapter. I set the second adapter to a gallery. The idea is that I can sort have pages in an album where there are multiple pictures on each album.
Now I want to the imageViews to fire off clicks, so I set an onClickListener for each of the imageViews from the imageAdapter. The problem is that after I set the onClickListener, I cannot scroll the gallery by touch/fling/scrolling on the images anymore. I think it's an issue of parent/children event pass through thing.. but I am not sure how to fix it exactly. Please help.
This is a wild guess based on an experience with ListView (where one clickListener worked but the parent onClickListener did not), but setting the onClickListener on the imageViews might have made it so they have taken away the focus, and now your other touch events are not registering.
try setting myImageView.setFocusable(false)
I am assuming that everything worked as expected before you added the onClickListener to the ImageViews.
I solved this problem by subclassing Gallery and overriding onDown() and onSingleTapUp(). I have to also implement a pointToChildId() method to translate motion events to item ids. =) it was a lot more work than I initially planned for, but it works now and I am quite happy with the solution.

Categories

Resources