Search code examples
androidandroid-actionbar

Removing left arrow from the actionbar in android?


I want to remove the left arrow from the action bar and only icon and title needed.

My code:

getSupportActionBar().setIcon(R.drawable.logo);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(R.string.dashboardtitle);
getSupportActionBar().setDisplayHomeAsUpEnabled(false);

But this doesn't remove the left arrow . Any help!!


Solution

  • According to specification android specification: To enable the icon for up navigation (which displays the "up" indicator next to the icon), call setDisplayHomeAsUpEnabled(true) on your ActionBar:

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        setContentView(R.layout.main);
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        ...
    }
    

    So you should set actionBar.setDisplayHomeAsUpEnabled(false);

    UPDATE: I test next code with ActionBar sherlock and it's work. There is no back arrow:

    getSupportActionBar().setIcon(R.drawable.ic_launcher);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setTitle(R.string.about_event_location);
    getSupportActionBar().setDisplayHomeAsUpEnabled(false);