在列表视图中格式化文本视图
我有一个包含一些项目的 ListView。我想设置 ListView,其中某些项目带有删除线。我知道如何使用 onclicklistener 来实现它,但我想加载带有已标记删除线项目的 ListView 。
所以我启动我的程序,效果应该是这样的:
第一个/strikethrough/
第二个
第三个
第四个/strikethrough/
I have a ListView with some items. I'd like to set ListView where some items are strikethrough. I know how to make it using onclicklistener, but I'd like to load ListView with already marked strikethrough items.
So I start up my programm and an effect should be something like this:
first /strikethrough/
second
third
fourth /strikethrough/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要自定义列表视图,您可能需要创建一个自定义 ListView ArrayAdapter ,它将加载您的文本视图并将其设置为删除线:
To customize your list view you probably need to make a Custom ListView ArrayAdapter which will load your text view and set it to strikethrough:
如果要从 SimpleAdapter 加载数据,请重写 SimpleAdapter.setViewBinder 方法。当您执行 ListView.SetAdapter(SimpleAdapter) 以使用 SimpleAdapter 中的数据填充 Listview 时,将使用此方法。重写此方法以删除所需的行,但请确保包含以下代码行:
这些代码是为了确保显示列表视图项目文本。
If you are loading data from a SimpleAdapter, override the SimpleAdapter.setViewBinder method. This method is used when you execute ListView.SetAdapter(SimpleAdapter) to fill your Listview with data from the SimpleAdapter. Override this method to strikethrough your needed rows, but make sure to include the following lines of code:
These are to ensure that your listview items text appear.