亦余心之所善兮,虽九死其犹未悔。这篇文章主要讲述ActionBar Android Appcelerator中的后退按钮[复制]相关的知识,希望能为你提供帮助。
这个问题在这里已有答案:
- android: how to remove the back/home button in the action bar 7个答案
此按钮不会出现在我看来。我用了重窗。 android sdk-version 27 SDK Titanium 7.0.0.GA
答案【ActionBar Android Appcelerator中的后退按钮[复制]】您可以像这样添加Action Bar:
<
Alloy>
<
Window title="Action Bar Title">
<
ActionBar platform="android" displayHomeAsUp="true" onHomeIconItemSelected="close">
<
/ActionBar>
<
/Window>
<
/Alloy>
您甚至可以添加字幕,菜单项,溢出菜单,图标甚至自定义视图。
阅读更多关于使用Action Bar in Titanium here的信息
为了更好地控制ActionBar以进行完全自定义,Titanium在SDK 6.2.0中引入了工具栏 -Read about Titanium Android Toolbar here
另一答案在onCreate中写下这个
{
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
覆盖onOptionsItemSelected方法
public boolean onOptionsItemSelected(MenuItem item) {switch (item.getItemId()){case android.R.id.home:
onBackPressed();
break;
}
}
return super.onOptionsItemSelected(item);
}
推荐阅读
- Android ActionBar(文本未显示图标)
- 带有ActionBarDrawerToggle的Android菜单
- 从URL设置MenuItem图标 - Android
- 如何在Android中更改Action栏的高度()
- Android导航组件“向上按钮”打开抽屉导航
- 如何在android中找到系统Action Bar中存在的不同图标的宽度
- 隐藏Android Action Bar解决方案
- 将android EditText样式从矩形边框更改为下划线
- 在Theme.AppCompat.Light中添加图标