Android carousel image gallery

元气小坏坏 提交于 2019-12-01 07:27:55

问题


How can i carousel image gallery which never gets end.. after last first image and before first last image.


回答1:


I did this by creating my own list-adapter (subclassed from BaseAdapter). I coded my own list-adapter in such a way that its getCount() method returns a HUUUUGE number. And if item 'x' is selected, then this item corresponds to adapter position='adapter.getCount()/2+x' And for my adapter's method getItem(int position), i look in my array that backs up the adapter and fetch the item on index: (position-getCount()/2) % myDataItems.length You need to do some more 'special' stuff to make it all work correctly, but you get the idea. In principle, it is still possible to reach the end or the beginning of the list, but if you set getCount() to around a million or so, this is hard to do :-)



来源:https://stackoverflow.com/questions/2854771/android-carousel-image-gallery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!