我按照此answer中提到的步骤为列表视图设置了工具栏[listview image] [1]。
现在列表项不可点击。使用ListActivity时,列表项是可点击的,当点击任何项目时,它将打开另一个带有项目标题及其内容的活动。
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Note note = posts.get(position);
Intent intent = new Intent(this, EditNoteActivity.class);
intent.putExtra("noteId", note.getId());
intent.putExtra("noteTitle", note.getTitle());
intent.putExtra("noteContent", note.getContent());
startActivity(intent);
}
答案 0 :(得分:2)
这样做
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Note note = posts.get(position);
Intent intent = new Intent(this, EditNoteActivity.class);
intent.putExtra("noteId", note.getId());
intent.putExtra("noteTitle", note.getTitle());
intent.putExtra("noteContent", note.getContent());
startActivity(intent);
}
});