private void initialize() { Intent i = getIntent(); todoItem = (ToDoItem) i.getSerializableExtra("item"); EditText editText = (EditText) findViewById(R.id.title); editText.setText(todoItem.getTitle()); editText = (EditText) findViewById(R.id.description); editText.setText(todoItem.getDescription()); Switch todoCompletedSwitch = (Switch) findViewById(R.id.completed_switch); todoCompletedSwitch.setChecked(todoItem.isCompleted()); // this works too, but since a instance item is needed for // onOptionsItemSelected, this is not needed anymore // Button submitButton = (Button) findViewById(R.id.update); // submitButton.setTag(item); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.todoDelete: new DeleteToDoAsncTask(UpdateTodoActivity.this, todoItem.getId()).execute(); return true; default: return true; } }