Clicking on individual menu items, we just display the toast message. Like we said earlier, we want to make the code concise and easily readable. Based on the chapters we covered earlier, we should have an understanding of how to perform data synchronization for these individual menu actions. We have used the onMenuItemClick
class to perform the menu listener activity, shown as follows:
@Override public boolean onMenuItemClick(MenuItem menuItem) { Log.d(TAG, "onMenuItemClick(): " + menuItem); final int itemId = menuItem.getItemId(); String toastMessage = ""; switch (itemId) { case R.id.menu_add_todo: toastMessage = "Adding " + mSelectedTodoItemType.getTypeValue() + " Todo"; break; case R.id.menu_update_todo: toastMessage = "Updating " + mSelectedTodoItemType.getTypeValue() + " Todo"; break; case R.id.menu_clear_todos: toastMessage = "Clearing " + mSelectedTodoItemType.getTypeValue() + " Todos"; break; ...