如何更改不再在屏幕上的可扩展列表视图子项的背景
在 setOnChildClickListener 中,我可以使用 v.setBackgroundResource(R.color.blue);
更改子项的背景(我无法使用 xml 列表项选择器,因为我正在做一些分屏内容和焦点丢失)当选择另一个孩子时,我还可以将颜色设置回来。但是,当选定的子项滚动到屏幕外时,它不会返回到原始颜色,并且当父项折叠时,如果选择了该父项内的子项,它将跳到下一个父项并更改父项的背景那里的孩子,因为根据 android 的说法,折叠的行不再存在。关于如何修复这些错误有什么建议吗?
In a setOnChildClickListener, I am able to change the background of a child item with v.setBackgroundResource(R.color.blue);
(I can't use an xml list item selector because I am doing some split screen stuff and focus gets lost) I am also able to set the color back when another child is selected. However, when a selected child is scrolled off screen, it does not go back to the original color and when a parent is collapsed, if a child inside that parent was selected, it will hop down to the next parent and change the background of a child in there since the collapsed rows no longer exist according to android. Any tips on how to fix these bugs?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要存储选择的项目,然后创建一个自定义适配器,该适配器在其 getView() 方法中返回具有适当背景的视图
You need to store which item was selected, then make a custom adapter which in its getView() method returns a view with the appropriate background