Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a custom back button in ActionBar?

I am creating an ActionBar (SupportActionBar, more precisely) this way:

android.support.v7.app.ActionBar actionBar=getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    //actionBar.setDisplayOptions(actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE););
    actionBar.setIcon(R.drawable.ic_drawer);
    actionBar.setTitle(mTitle);

This way, I get a button in my action bar which, once clicked, does what I want it to do. But, it displays an arrow pointing to the left. I would like to display another drawable, so I uncomment the setDisplayOptions line, and the icon I want is displayed. But, the button is no longer clickable.

How could I set my drawable to the button, and maintaining it clickable?

like image 757
Fustigador Avatar asked Sep 18 '25 23:09

Fustigador


1 Answers

Use setHomeAsUpIndicator() method instead

actionBar.setHomeAsUpIndicator(R.drawable.ic_drawer);
like image 136
Maksim Ostrovidov Avatar answered Sep 20 '25 15:09

Maksim Ostrovidov