我有一个ListView
装满物品。我想设置一个onClickListener
以显示有关单击的项目的详细信息。如何确定在 中单击了哪个项目onClickListener
?,View
或v
有很多可用的方法,我已经查看过并且没有看到任何与单击对象有关的内容。
//populate the activity list
ListView teamsListView = (ListView) activity.findViewById(R.id.teamsListView);
ArrayList<HashMap<String, String>> listData = new ArrayList<HashMap<String, String>>();
HashMap<String, String> listItem;
for (TeamSet teamSet : response.getTeamSetList()) {
listItem = new HashMap<String, String>();
listItem.put("name", teamSet.getName());
//listItem.put("teamCount", Integer.toString(teamSet.getTeams().size()));
listData.add(listItem);
}
teamsListView.setAdapter(
new SimpleAdapter(
context,
listData,
R.layout.teams_list_row,
new String[]{"name"},
new int[]{R.id.teamsTeamListName}
)
);
//show details on a team
TextView team = (TextView) activity.findViewById(R.id.teamsTeamListName);
team.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//how do I know which item was clicked? I want to load more details on the item...
}
});