行动栏图标继续显示后面的图标

时间:2015-05-14 21:07:02

标签: android android-fragments android-actionbar

我在开发Android应用程序时非常新。我的项目在片段之间使用导航抽屉我试图用教程http://www.tutecentral.com/android-custom-navigation-drawer/自定义抽屉并出错。在我的应用程序中,在操作栏中,它会一直显示后退图标而不是默认图标。

这是操作栏前后图像的网址:http://oi58.tinypic.com/2ahsbys.jpg

这里是我感到困惑的代码(与教程非常相似,告诉我是否有我错过的内容)

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
            R.drawable.ic_drawer, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to
            // onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to
            // onPrepareOptionsMenu()
        }
    };

如果我删除了setDisplayHomeAsUpEnabled,后面的图标就消失了,但我无法点击某处显示抽屉,我必须将其滑动。如果有人解决了,请转介我。非常感谢。

*我已将R.drawable.ic_drawer更改为其他可绘制图标,但它没有效果。

1 个答案:

答案 0 :(得分:1)

尝试为activity文件中的manifest设置一个主题,并在styles.xml内为该主题设置homeAsUpIndicator的可绘制

<style name="CustomTheme" parent="@style/Widget.AppCompat.ActionBar"> 
     <item name="homeAsUpIndicator">@drawable/ic_drawer</item> 
</style>
相关问题