AppCompatActivity 中的 onlistitemclick
onlistitemclick in AppCompatActivity
我按照此 中提到的步骤为列表视图设置工具栏 [列表视图图像][1]。
现在列表项不可点击。当使用 ListActivity 列表项是可点击的时,当点击任何项目时它会打开另一个 activity 带有项目标题和它的内容。
@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);
}
这样做
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);
}
});
我按照此
现在列表项不可点击。当使用 ListActivity 列表项是可点击的时,当点击任何项目时它会打开另一个 activity 带有项目标题和它的内容。
@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);
}
这样做
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);
}
});