如何设置ID为ListView的每个项目 [英] how to set id for each item in ListView
问题描述
当我从数据库中检索数据时,我对每一行的唯一ID我想在列表视图,但ID我希望它是无形的,所以,当我在列表视图中单击任意项目转我到另一个活动有数据串匹配ID有关这个项目的。
When I retrieve data from database, I have for each row unique ID I want match id with string in listview but ID I want it to be invisible, so that when i click any item in listview trans me to another activity have data about this item.
这意味着我有两个表中的数据库匹配在一起我想要检索一个作为列表视图,当点击项目跨我的数据相匹配,我一直在为clicked.one列表视图的项目,当点击项目跨我的数据相匹配的项目我已经被点击。
That means I have Two table in database match together I want to retrieve one as listview , when click item trans me to data match the item i have been clicked.one as listview , when click item trans me to data match the item i have been clicked.
我怎样才能做到这一点?
How can I do this?
推荐答案
这应该工作
myAdapter.setViewBinder(new MyViewBinder());
public class MyViewBinder implements ViewBinder {
@Override
public boolean setViewValue(View view, Object data, String text){
//Since it iterates through all the views of the item, change accordingly
if(view instanceof TextView){
((TextView)view).setTag("whatever you want");
}
}
}
这篇关于如何设置ID为ListView的每个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!