这个例子:http://saigeethamn.blogspot.com/2010/04/custom-listview-android-developer.html . 在custom_row_view.xml中有3个textview id . 使用onListItemClick时,一个位置列表项内有3行数据 . 如何提取这些数据?如何使用id?无论如何,当单击列表项时,在列表视图中获取行视图数据[protected void onListItemClick(ListView l,View v,int position,long id)?
4 回答
参数
View v
本身是行视图 . 您可以通过调用v.getTag()
来获取附加数据 . 应该使用v.setTag(Object)
在适配器的getView中设置它取决于数据类型 . 例如,id确实包含来自使用CursorAdapters之一设置的数据库表行的_id . 通常这是该数据库表行的PK .
获取绑定到视图V的对象
我建议你不要从视图中获取数据,而是 use the ArrayList you have used to set data to the Adapter of the ListView .
在您指出的示例中,您使用的是HashMap的ArrayList . 所以举个例子..