且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

android-使用自定义cursoradapter的listview中的隐藏字段

更新时间:2022-06-01 02:39:12

onItemClick(AdapterView<?>父级中使用 CursorAdapter 时,查看视图,int位置,长id) AdapterView.OnItemClickListener 实现,您可以获得:

When you are working with CursorAdapter in onItemClick(AdapterView<?> parent, View view, int position, long id) implementation of AdapterView.OnItemClickListener you can get:

  1. 基础游标中的 _id 列-简单来说,它是此函数的 long id 参数
  2. 在项目视图中可见或不可见但存在于Cursor中的任何列,方法是将项目投射到Cursor的位置,例如:

  1. the _id column from the underlying Cursor - simply, it is the long id parameter of this function
  2. any column visible or not in your item view but existing in the Cursor by casting the item at position to the Cursor like:

光标c =(光标)parent.getItemAtPosition(位置);

现在 c 指向选定的行,因此您可以从中获取任何列,就像 var value = c.getInt/String/etc(c.getColumnIndex("columnname));

Now c is pointing to the selected row so you are can get any column from it as simple as var value = c.getInt/String/etc(c.getColumnIndex("columnname"));