简体   繁体   English

Android轮播图片库

[英]Android carousel image gallery

我该如何轮播永无休止的图片库。。

I did this by creating my own list-adapter (subclassed from BaseAdapter). 我通过创建自己的列表适配器(从BaseAdapter继承而来)来完成此操作。 I coded my own list-adapter in such a way that its getCount() method returns a HUUUUGE number. 我对自己的列表适配器进行了编码,以使其getCount()方法返回HUUUUGE数字。 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. 如果选择了项“ x”,则该项对应于适配器位置=“ adapter.getCount()/ 2 + x”。对于适配器的方法getItem(int position),我在备份适配器的数组中查找并获取索引上的项目:(position-getCount()/ 2)%myDataItems.length您需要执行更多“特殊”操作才能使其正常工作,但是您明白了。 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 :-) 原则上,仍然可以到达列表的末尾或开头,但是如果将getCount()设置为大约一百万左右,则很难做到这一点:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM