// Method to handle menu selections on the app bar @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. switch (item.getItemId()) { case R.id.action_settings: // TODO: Implement actual settings and bind to action return true; case R.id.action_new_task: if (pager.getCurrentItem() == 0) { createTask(); } else { createNote(); } return true; case R.id.action_delete_all_tasks: dbHelper.remakeTaskTable(); TasksFragment tf = (TasksFragment) adapter.getRegisteredFragment(pager.getCurrentItem()); tf.populateTaskList(); return true; default: // None of our actions were initiated, refer to super class return super.onOptionsItemSelected(item); } }
// Method to handle data returned from a finished activity started by this activity @Override protected void onActivityResult(int resultCode, int requestCode, Intent data) { if (resultCode == CREATE_TASK_REQUEST) { if (requestCode == RESULT_OK) { // update list of tasks TasksFragment tf = (TasksFragment) adapter.getRegisteredFragment(pager.getCurrentItem()); tf.populateTaskList(); } } }