0

Im noob in framework appcelerator and I have a simple problem in android. I dont know how put the backbutton in ActionBar like this link image

This button does not appear to me. I used heavywindow. android sdk-version 27 SDK Titanium 7.0.0.GA

kurungele
  • 5
  • 3
  • simply add this line to your code getActionBar().setDisplayHomeAsUpEnabled(false); or if using AppCompactActivity getSupportActionBar().setDisplayHomeAsUpEnabled(false) – Vivek Barai Dec 18 '17 at 11:21

2 Answers2

3

You can add Action Bar like this:

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

You can even add Subtitle, Menu Items, Overflow Menu, icons, & even custom views.

Read more about using Action Bar in Titanium here

For more control over ActionBar for full customizations, Titanium has introduced Toolbar in SDK 6.2.0 - Read about Titanium Android Toolbar here

Prashant Saini
  • 3,539
  • 1
  • 10
  • 24
-1

write this in onCreate

   {
          getSupportActionBar().setHomeButtonEnabled(true);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
         getSupportActionBar().setDisplayShowHomeEnabled(true);

override onOptionsItemSelected method

          public boolean onOptionsItemSelected(MenuItem item) {

           switch (item.getItemId()){

              case android.R.id.home:
            onBackPressed();
                break;
        }
  }
        return super.onOptionsItemSelected(item);

}
Laksh
  • 21
  • 7
  • Before writing answers, do read questions properly. User is asking to add ActionBar in Appcelerator, not in native Android. – Prashant Saini Dec 18 '17 at 14:36