/** * Called when a list item is selected. * * <p>Updates the state of the list, closes the drawer, and fowards the event to the parent * activity to handle. * * @param position position of the item in the list */ public void selectItem(int position) { mCurrentSelectedPosition = position; if (mDrawerLayout != null) { mDrawerLayout.closeDrawer(mNavigationDrawerContainer); } if (mCallbacks != null) { NavDrawerItem navDrawerItem = mAdapter.getItem(position + 1); mCallbacks.onNavigationDrawerItemSelected( navDrawerItem, null != navDrawerItem ? navDrawerItem.getTitle() : null); } mAdapter.notifyDataSetChanged(); }
@Override public void onBindViewHolder(MyViewHolder holder, int position) { NavDrawerItem current = data.get(position); holder.title.setText(current.getTitle()); }