仅在单击时更改可绘制的项目状态 - GalleryView
我使用 GalleryView 通过 BaseAdapter 显示字符串
根据项目状态(选择器)更改背景和文本颜色没有问题
但我只想在单击该项目而不仅仅是选择该项目时更改背景和文本颜色,GalleryView 项目状态会随着您四处滑动时调用的选定事件而变化(自动选择居中的项目)
用 2 个字来说,如果未单击该项目,则背景不得更改
我该如何处理呢?
I use a GalleryView to display string with a BaseAdapter
No problem to change the background and text color depending on the item state (selector)
But I want to change the background and text color only if the item is clicked not just selected, the GalleryView item state changes with the selected event which is called when you fling around (the centered item is automatically selected)
In 2 words the background mustn't change if the item isn't clicked
How can I go with it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须使用属性
android:listSelector
在 xml 中实现列表选择器,然后将此样式设置为列表视图。You must implement a list selector in you xml using the attribute
android:listSelector
and then set this style to your list view.您必须捕获选定的事件并将视图的背景更改为未选定。
存储上次单击的位置以避免更改其选定的背景。此外,存储上次单击的视图,以便在单击另一个项目而不进行快速操作时恢复未选择的背景:
如果对您来说为时已晚,Fluckysan 至少希望它对遇到相同问题的任何人有所帮助。
快乐编码!
You must capture the selected event and change the background of the view to unselected.
Store last clicked position to avoid changing its selected background. Also, store last clicked view to restore unselected background when another item is clicked without flinging:
If it's too late for you Fluckysan at least hope it helps to anyone who's having the same problem.
Happy coding!