about the Android toolbar, how to hide the default setting menu in the toolbar


about android Toolbar, how to hide default setting menu in toolbar

in the this activity i hava set a single icon menu,like this –

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

it is menu/main_home.xml

public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_home, menu);
    return super.onCreateOptionsMenu(menu);

but it show a three dots menu. i want know why

and how to show sub menu icon image ,it is normal in the Actionbar, but hide in the Toolbar

  1. If you want to empty the contents of the menu, go to the res/menu folder and delete the item tags from the menu_main.xml file. You will also need to delete references to the items in onOptionsItemSelected(MenuItem item). The menu dots will disappear if there are no items.

  2. If you want to completely remove the three dots menu, then go to the onCreateOptions(...) method in your code and delete it, or simply remove the getMenuInflater().inflate(...); portion of it. You can safely remove the onOptionsItemSelected(MenuItem item) method as well because it will have no purpose.

  3. The simplest way to make the menu disappear is to have the onCreateOptions(...) method return false.