ActionBar Android Appcelerator中的后退按钮[复制]

亦余心之所善兮,虽九死其犹未悔。这篇文章主要讲述ActionBar Android Appcelerator中的后退按钮[复制]相关的知识,希望能为你提供帮助。
这个问题在这里已有答案:

  • android: how to remove the back/home button in the action bar 7个答案
我在框架appcelerator中的noob,我在android中有一个简单的问题。我不知道怎么把Backbutton放在ActionBar中就像这个link image
此按钮不会出现在我看来。我用了重窗。 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); }


    推荐阅读