使用SimpleAdapter当列表视图项设置标签 [英] Setting tag for listview item when using SimpleAdapter

查看:139
本文介绍了使用SimpleAdapter当列表视图项设置标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用来存储一些数据(假设ID)在每个的ListView 项目,并在以后检索它 clickItem 监听器。

I would like to store some data (let's say ID) in each ListView item and retrieve it later on clickItem listener.

我知道该怎么做,如果我创造我自己的适配器。但它是可能的,如果我使用的设置一个唯一的标签为每个项目 SimpleAdapter

I know how to do that if I create my own adapter. But is it possible to set a unique tag for each item if I am using SimpleAdapter?

推荐答案

如果没有至少覆盖 getView(),你将有每一个适配器的看法回收麻烦设置标签。

Without overriding at least getView(), you will have trouble setting tags with every Adapter's view recycler.

但是,您可以简单地传递一个自定义布局与具有其可见性设置为 GONE 看不见和一个TextView从您的地图列表绑定数据(;地图<字符串,>> 名单,LT )。稍后,您可以轻松地在OnItemClickListener取这个TextView的。

However you can simply pass a custom layout with a TextView that has its visibility set to GONE or INVISIBLE and bind data from your List of Maps (List<Map<String, ?>>). Later you can easily fetch this TextView in an OnItemClickListener.

这篇关于使用SimpleAdapter当列表视图项设置标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆