2017-12-18 70 views
0

Im noob在框架appcelerator和我有一个简单的问题在Android中。我不知道如何把这个按钮在这样的ActionBar link imageActionBar中的Backbutton Android Appcelerator

这个按钮不会出现在我身上。我用重窗帘。 Android SDK中版本27 SDK钛7.0.0.GA

+0

只是这一行添加到您的代码 getActionBar( ).setDisplayHomeAsUpEnabled(假); 或如果使用AppCompactActivity getSupportActionBar()。setDisplayHomeAsUpEnabled(false) –

回答

2

您可以添加操作栏是这样的:

<Alloy> 
    <Window title="Action Bar Title"> 
     <ActionBar platform="android" displayHomeAsUp="true" onHomeIconItemSelected="close"></ActionBar> 
    </Window> 
</Alloy> 

你甚至可以添加小标题,菜单项目,溢出菜单,图标,&甚至自定义视图。

了解更多关于使用Action Bar in Titanium here

为了更好地控制动作条完全自定义,钛推出了工具栏的SDK 6.2.0 - Read about Titanium Android Toolbar here

+0

非常感谢。你解决了我的问题。 – kurungele

+0

欢迎!将此答案标记为已接受,以便其他用户可以参考此答案。 –

0

写这篇文章的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); 

} 
+0

在写答案之前,请正确阅读问题。用户要求在Appcelerator中添加ActionBar,而不是在原生Android中添加。 –