我有listview,它通过KEY_TITLE(字段)从sqlite和组绑定,所以我需要获取被点击的项目的名称
@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
super.onListItemClick(l, v, position, id);
Intent i=new Intent(this,detail.class);
i.putExtra(DatabaseIN.KEY_TITLE,SOMETHING THAT I NEED!);
//startActivity(i);
startActivityForResult(i,ACTIVITY_EDIT);
}
//也许像这个字符串selectedIteme = l.getSelectedItem()。getSOMETNIG?
答案 0 :(得分:4)
查看本教程可能会对您有所帮助 http://www.vogella.de/articles/AndroidListView/article.html
您可以像这样选择所选的项目值
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Cursor c = (Cursor) arg0.getAdapter().getItem(arg2);
Intent i=new Intent(getApplicationContext(),Xyz.class);
i.putExtra("abc", c.getString(1));
startActivity(i);
}
答案 1 :(得分:2)
在onClick方法中试试这个..
Map<String, String> selection = (Map<String, String>) listView.getItemAtPosition(position);
String count = selection.get("count");
String title = selection.get("title");