Actions on gallery view android
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);
精彩评论