つまり、基本的にデータベースからのレコードがあり、各レコードには独自の一意の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);
}
});
助けてください。