Example usage for android.widget Toolbar setNavigationIcon

List of usage examples for android.widget Toolbar setNavigationIcon

Introduction

In this page you can find the example usage for android.widget Toolbar setNavigationIcon.

Prototype

public void setNavigationIcon(@Nullable Drawable icon) 

Source Link

Document

Set the icon to use for the toolbar's navigation button.

Usage

From source file:org.cyanogenmod.theme.chooser.ChooserActivity.java

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

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setActionBar(toolbar);/* w w  w. j a va  2s  . co  m*/
    toolbar.setNavigationIcon(R.drawable.ic_menu);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (mDrawerLayout.isDrawerOpen(mDrawerContainer)) {
                mDrawerLayout.closeDrawer(mDrawerContainer);
            } else {
                mDrawerLayout.openDrawer(mDrawerContainer);
            }
        }
    });

    initDrawer();

    NotificationHijackingService.ensureEnabled(this);

    if (savedInstanceState == null) {
        handleIntent(getIntent());
    }
}