기본적으로 데이터베이스의 레코드를 가지고 있으며 각 레코드는 고유 한 ID (기본 키)와 해당 날짜 (mm : hh mm/dd/yy)를 가지고 있습니다. 이러한 레코드를 내 app의 listview에 표시하고 싶습니다. 하지만 시간이 (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);
}
});
도와주세요.
당신이 옳습니다! 정말 고마워 –