I'm trying to re-create the menu on the toolbar. That it was possible to display there new elements with different id. While I was looking for information on the network, I realized that it is possible to hypothetically remove all the elements and add new ones with the necessary id, titles, and so it is possible to solve my problem. But maybe you can somehow recreate the menu so that in this function:
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.message_list_menu, menu); return true; } it was possible to use not only this one line:
getMenuInflater().inflate(R.menu.message_list_menu, menu); and do something like this:
@Override public boolean onCreateOptionsMenu(Menu menu) { switch (menu_item) { case 1: getMenuInflater().inflate(R.menu.message_list_menu, menu); break; case 2: Toast.makeText(this,"2",Toast.LENGTH_LONG).show(); break; case 3: Toast.makeText(this,"3",Toast.LENGTH_LONG).show(); break; } return true; } maybe there is some more or less working way? I hope that I will not have to remove and add elements dynamically.