【问题标题】:Actionbar set the home buttonActionbar 设置主页按钮
【发布时间】:2013-08-21 09:44:17
【问题描述】:
我正在使用NavigationDrawer 和我的ActionBar。它需要主页按钮并配置为向上。
我尝试在动作中间放置一个按钮。我发现的唯一方法是使用自定义布局。
但是当我使用它时,我的主页标题被删除了。即使它有空间可以展示。
有没有办法将主页按钮设置为始终显示他的标题?
如果没有,还有其他技巧吗?
提前致谢:)
【问题讨论】:
标签:
android
android-layout
android-actionbar
android-custom-view
【解决方案1】:
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setHomeButtonEnabled(true);
并添加
// For back Button
@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
Intent homeIntent = new Intent(this, DashbordActivity.class);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(homeIntent);
}
return (super.onOptionsItemSelected(menuItem));
}
【解决方案2】:
试试下面的代码
actionBar.setDisplayShowHomeEnabled(true);
actionBar.setHomeButtonEnabled(true);