如何更改颜色并删除单击的列表视图项?
我在程序中使用列表视图来扩展活动。我需要更改单击的列表项的颜色并删除单击的列表项。怎么做呢?非常感谢任何帮助,并提前致谢...
I am using listview in my program that extends activity. I need to change the color of the clicked list item and strike out the clicked list item. How to do it? any help is really appreciated and thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要为列表项创建自定义背景可绘制对象。
此链接有帮助: http://developer.android.com/guide/topics /resources/drawable-resource.html
You'll need to create your custom background drawable for list item.
this links helps: http://developer.android.com/guide/topics/resources/drawable-resource.html
那么您可以将 OnItemClickListener 添加到列表视图。当选择一个项目时。设置该项目的背景并在文本视图上使用以下代码将其删除
Well you could add a OnItemClickListener to the list view. And when a item is selected. Set the background of that item and use the following code on the textview to strike it out
您需要为列表构建自定义适配器。
此外,在自定义适配器中,您将需要覆盖该功能
,这样您就可以在选择时以及在某些操作后返回时执行文本删除单元格颜色更改。
请输入您列表中的代码片段,适配器将为您提供更好的帮助。
维布
You need to build the custom adapter for the List.
Also in Custom adapter will need to override the function
This way you can do Text Striking out cell color change on selection and when it comes back after some operation.
Please either put your code snippet of you list and adapter will help you better than.
Vib