I am trying to populate a list view with a data set that contains a name and an Id number. I know that I pass an array to the view adapter but 开发者_JS百科do not know how to associate the press to the ID number.
How do you handle this functionality?
Can any one point me to any tutorials?You better create custom adapter and set OnClickListener inside the custom adapter. here is something you can use
http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/
There is a property of everyview called Tag , e.g. TextView.setTag()
Use it when you are creating listview like listitem.setTag(ID Number);
In the onItemClickListener , you get the reference to the listitem on which you clicked, use it to retrieve the tag.
You want an onitemclicklistener for your listview Can't link you from my phone, but its on the android developer docs
Link: http://developer.android.com/reference/android/widget/ListView.html
精彩评论