应用图标未显示在Android操作栏中

5
我正在尝试使用支持库创建一个应用程序,并尝试将动作栏添加到其中。动作栏可以正常工作,但是没有显示公司图标。我在清单文件和程序中都指定了图标和标志,但仍然无法正常工作。
在我的代码中,我有这段内容:
    //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);

在清单文件中,我有这个内容:
<application
    android:icon="@drawable/ic_launcher"
    android:logo="@drawable/ic_launcher"
    ... >
    ...
</application>

Please help.


1
你正在使用AppCompat 21版本吗?你知道NAVIGATION_MODE_TABS在21版本中也已经被弃用了吗? - ianhanniballake
2个回答

3

这个可以在Android 5.0上本机操作栏中显示图标:

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

我不能确定它是否与appcompat-v7操作栏兼容,因为我尚未尝试过。


0

不要使用com.android.support:appcompat-v7:22.0.0

尝试使用:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:19.0.0'
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接