私はこのコードを持っています:
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Log.i(TAG, "The id of the selected note is " + id);
Intent editNote = new Intent(this, TaskEditActivity.class);
editNote.putExtra(TasksDBAdapter.KEY_ID, id);
startActivityForResult(editNote, EDIT_TASK_REQUEST);
}
そして、異なるアクティビティから余分なものを取得するこのコード:
if (savedInstanceState != null) {
id = savedInstanceState.getLong(TasksDBAdapter.KEY_ID);
}
Log.i(TAG, "Id of note = " + id);
最初のコードスニペットでは、Logcatは次のように述べていますThe id of the selected note is 2
が、2番目のコードスニペットでは、Logcatは次のように述べていますId of note = 0
。ここで何が起こったのですか?この非常に厄介な問題の解決策。