I'm writing a chat. After getting the list of rooms, you need to create new menu items (navigationdrawer) in the side menu. Create it turns out, but I do not know how to handle pressing such items. I create points in this way:

menu.add(R.id.group1,Menu.NONE,Menu.NONE,JSONrooms.getJSONObject(i).getString("roomName")); 

menu items

    1 answer 1

    As you can see from the documentation , the second parameter in the add method is itemId. Pass some unique identifier into it onNavigationItemSelected you will understand which item has been selected by the onNavigationItemSelected method.