[英]Link Id from data in database, to custom ArrayAdapter, to listView
I am creating a custom listview.我正在创建一个自定义列表视图。
The data is not coming from a cursor but from an ArrayAdapter
of my own class, which contains data coming from a cursor.数据不是来自 cursor,而是来自我自己的 class 的ArrayAdapter
,其中包含来自 cursor 的数据。
I've managed to create the custom list view, but when implement the onListItemClick
method, then I get an id for that row, that is not the same id for that data in the database.我设法创建了自定义列表视图,但是当实现onListItemClick
方法时,我得到了该行的 id,这与数据库中该数据的 id 不同。
How do I link the _id of the items in my database into my list, using my custom ArrayAdapter
?如何使用我的自定义ArrayAdapter
将数据库中项目的 _id 链接到我的列表中?
Have your custom ArrayAdapter
implement getItemId(int position)
using the data from the cursor's _id column.让您的自定义ArrayAdapter
使用光标的 _id 列中的数据实现getItemId(int position)
。 Once you've done that, it should be provided to you as the id
argument to onListItemClick
.完成后,它应该作为onListItemClick
的id
参数提供给您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.