0

For my App i need to show icon in toolbar. So I referred a question on stackoverflow

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);

I applied the same to my code but after running the app i noticed my navigational drawer icon i.e. hamburger gone missing.

How can i get it back along with the app icon?

Somesh Kumar
  • 8,088
  • 4
  • 33
  • 49

2 Answers2

2

Remember, ToolBar is the more customizable version of ActionBar, and are two different things, though they basically follow the same pattern. My answer is to user Toolbar and customize it for the required view instead of using the default ActionBar. If you are using the customized ToolBar, then the below code is not going to work.

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);

Use ToolBar.

bijaykumarpun
  • 677
  • 4
  • 9
0

Change from this

getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.ic_launcher);

To

getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_launcher);
Hobbit
  • 601
  • 1
  • 9
  • 22