-1

I want to get an image from server and show in action bar instead of icon. I wrote below code and tested and worked well in android 4.2 but when i installed my application in android 6.0.1, not showed.

getActionBar().setTitle("test");
getActionBar().setIcon(icon);

The android 6.0.1 version changed title with setTitle() code but can't add icon in my actionbar.

I tested setLogo method but not worked. How can i solve my problem?

Fahim
  • 384
  • 5
  • 20

2 Answers2

0

try following code , may help you.

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

use below code

 Toolbar toolbar = (Toolbar) findViewById(R.id.toolbarMain);
    setSupportActionBar(toolbar);
    setTitle("test");

    final ActionBar ab = getSupportActionBar();
    assert ab != null;
    //ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);

    getSupportActionBar().setLogo(R.drawable.logo1);
    getSupportActionBar().setDisplayUseLogoEnabled(true);
Omkar
  • 3,040
  • 1
  • 22
  • 42