2017-12-18 69 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中添加。 –