Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application icon doesn't show up in Android action bar

I'm trying to do an application using support libraries, and I tried to add an action bar to it. The action bar works just fine, but it doesn't show the company icon. I tried specifying icon and logo, in the manifest and programatically, but still, nothing works.

In my code, I have this:

    //Actionbar setup
    mActionBar = getSupportActionBar();
    mActionBar.setIcon(res.getDrawable(R.drawable.ic_launcher));
    mActionBar.setLogo(res.getDrawable(R.drawable.ic_launcher));
    mActionBar.setTitle("");

    //Tabs setup
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    tabConoce = mActionBar.newTab().setText(res.getString(R.string.conoce));
    tabExperimenta = mActionBar.newTab().setText(res.getString(R.string.experimenta));         
    frgConoce = new TabConoce();
    frgExperimenta = new TabExperimenta();
    tabConoce.setTabListener(new GeaTabListener(frgConoce));
    tabExperimenta.setTabListener(new GeaTabListener(frgExperimenta));
    mActionBar.addTab(tabConoce);
    mActionBar.addTab(tabExperimenta);

And in the manifest, I have this:

<application
    android:icon="@drawable/ic_launcher"
    android:logo="@drawable/ic_launcher"
    ... >
    ...
</application>

Please help.

like image 511
user2972112 Avatar asked Oct 20 '22 22:10

user2972112


1 Answers

This works with the native action bar on Android 5.0 to display an icon:

getActionBar().setLogo(R.drawable.ic_launcher);
getActionBar().setDisplayShowHomeEnabled(true);
getActionBar().setDisplayUseLogoEnabled(true);

Whether it works with the appcompat-v7 action bar, I cannot say, as I have not yet tried that.

like image 127
CommonsWare Avatar answered Oct 22 '22 11:10

CommonsWare