AdapterContextMenuInfo.idAdapterContextMenuInfo、id

2023-09-06 05:11:56 作者:再惹我便毁了天下

我在网上看这个问题。所以,我的理解是,AdapterContextMenuInfo.position是ListView中的项目的索引。

时AdapterContextMenuInfo.id在光标或在数据库中的项目的主密钥ID的项的索引?我已经用它在数据库中的项目的主密钥ID。是游标按主键索引?

解决方案   

时AdapterContextMenuInfo.id在光标或在数据库中的项目的主密钥ID的项的索引?

这是 _id 列,它是你的光标,里面当您使用的CursorAdapter 。

  

按主键索引游标?

光标不被索引,期。但是,要使用的CursorAdapter ,您必须在其名称 _id 。

I have looked online about this. So my understanding is that AdapterContextMenuInfo.position is the index of the item in the listview.

Is AdapterContextMenuInfo.id the index of the item in the Cursor or the primary key id of the item in the database? I have used it as the primary key id of the item in the database. Are cursors indexed by primary key?

解决方案 Android中各种Adapter的用法

Is AdapterContextMenuInfo.id the index of the item in the Cursor or the primary key id of the item in the database?

It is the value of the _id column that is inside your Cursor, when you are using a CursorAdapter.

Are cursors indexed by primary key?

Cursors are not indexed, period. However, to use CursorAdapter, you must have a column in the Cursor's result set that has the name _id.