Material Design Using Toolbar as Standalone

This post is related to my last post where i discussed using toolbar as an action bar. In this post i will discuss using it as standalone, now the situations will you be using the toolbar as a standalone may be summarized as

Here you see how to use it as standalone

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.my_layout);

  Toolbar toolbar = (Toolbar) findViewById(R.id.my_basic_toolbar);

  // Set an OnMenuItemClickListener to handle menu item clicks
  toolbar.setOnMenuItemClickListener(
    new Toolbar.OnMenuItemClickListener() {
      @Override
      public boolean onMenuItemClick(MenuItem item) {
        // Handle the menu item
        return true;
      }
      });

      // Inflate a menu to be displayed in the toolbar
      toolbar.inflateMenu(R.menu.my_toolbar_menu);
    }

#####Note

when using toolbar as standalone we don’t have to disable the action bar.Rest things are same as discussed in my previous post