isEnabled 用于带有 simpleCursorAdapter 的分隔符?
我有一个列表视图,其中填充了我覆盖的简单光标适配器。我有一个查询返回一个光标,该光标是一堆项目及其分隔符,按我需要显示的正确顺序排列。我的所有内容都显示正确,但我希望分隔符不可单击。我试图弄清楚如何重写 isEnabled() 方法,以便它为我的分隔符返回 false。 我的问题是我如何知道我的项目的位置,或者我可以将传递给此方法的 int 与什么进行比较,以便知道它是否是分隔符? 我想也许是 _id 列光标,但因为我从项目和类别(我的分隔符)的两个不同列中获取数据,所以 _id 很混乱,有时有重复的数字。另外,绘制行时这会给我带来问题吗?我最终会在行具有相同 _ids 的地方而不是我期望的行中绘制行吗?我尝试了更长的列表,看看滚动时是否会出现这种情况,但到目前为止我还没有遇到问题。
I have a listview that is populated with a simplecursoradapter that I overrode. I have a query that returns a cursor that is a bunch of items and their separators in the proper order that I need them displayed in. I have everything displaying correctly, but I would like the separators to not be clickable. I am trying to figure out how to override the isEnabled() method so that it returns false for my separators. My question is how do I know the position of my items or what can I compare the int that is passed to this method with in order to know if it is a separator? I thought maybe the _id column of the cursor, but because I took data from two different columns for items and categories (my separators) the _id's are jumbled, and sometimes have duplicate numbers. Also, will this cause a problem for me when the rows are drawn? Will I end up getting rows draw in places where the rows have same _ids instead of the row I expect? I tried longer lists to see if this would be the case while scrolling but I did not have an issue so far.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
isEnabled()
方法中传递的 int 是列表的行位置,您需要指定它是否是分隔符。您可以使用 moveToPosition 来确定该位置引用数据库的哪一行?
这完全取决于您如何查询数据库并确定哪些行是分隔符
不
the int passed in the
isEnabled()
method is the row position of the list for which you need to specify whether it is a separator or not.you can use moveToPosition to determine which row of the database does this position refer to ?
It completely depends on how you query the database and determine which rows are separators
NO