【发布时间】:2015-01-16 13:28:55
【问题描述】:
这是自从使用 android support ver7 在 android 2.x.x 中启用 Action Bar 以来,我第一次制作新应用程序。今天我只是安装了Android Studio(因为eclipse不再是android开发的官方工具)并用它来制作我的应用程序。我注意到当我运行应用程序时,主页按钮未显示在操作栏上。
我的代码中已经有这些行:
mainActionBar = getSupportActionBar();
mainActionBar.setCustomView(R.layout.search_bar);
mainActionBar.setHomeButtonEnabled(true);
mainActionBar.setDisplayShowCustomEnabled(true);
mainActionBar.setDisplayOptions(DISPLAY_SHOW_HOME| DISPLAY_SHOW_TITLE| DISPLAY_SHOW_CUSTOM);
但是主页按钮不显示在操作栏的角落。 然后我也尝试添加这些行:
mainActionBar.setDisplayShowHomeEnabled(true);
mainActionBar.setIcon(R.drawable.ic_launcher);
图标启动器已显示,但我可以按下它。
有人可以帮我解决吗?在我的旧应用程序中,我使用了 ActionbarSherlock,一切正常。 这是我的旧应用程序中的代码:
_action = getSupportActionBar();
_action.setCustomView(R.layout.search_bar);
_action.setDisplayShowCustomEnabled(true);
_action.setHomeButtonEnabled(true);
_action.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);
【问题讨论】:
标签: android android-studio android-actionbar