所以基本上我有来自数据库的记录,每条记录都有自己的唯一 ID(主键)和日期(mm:hh mm/dd/yy)我想在我的应用程序的列表视图中显示这些记录。但是有时间(mm:hh)有点难看所以我决定只在列表中显示mm/dd/yy,现在的问题是,当我对onitemClick进行编程时,我如何找出正在点击的项目?? 因为我没有唯一的 ID 和列表上显示的确切日期了。
ArrayList<HashMap<String, String>> aList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map;
for (int x = Records.size()-1; x >=0; x--)
{
map = new HashMap<String, String>();
map.put("ID", String.valueOf(Records.get(x).getId()));
map.put("date", Records.get(x).getDate()); //I am going to change this date to just mm/dd/yy
aList.add(map);
}
sd = new SimpleAdapter(this, aList, R.layout.historyactivityrow,
new String[]
{ "date" }, new int[]
{ R.id.date });
lv.setAdapter(sd);
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View view, int arg2,
long arg3)
{
TextView tx = (TextView) view.findViewById(R.id.date);
String s = tx.getText().toString();
Intent intent = new Intent(HistoryActivity.this, EditRecordActivity.class);
intent.putExtra("date", s); //I can't do this anymore because now the EditRecordActivity will not know the exact record to be edited.
startActivity(intent);
}
});
请帮忙。