0

This my code for set app icon in the Actionbar

    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(new ColorDrawable(Color.GRAY));
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setIcon(R.drawable.menuaction);
Athira
  • 1,177
  • 3
  • 13
  • 35
Bivin OC
  • 131
  • 16
  • you can make custom toolbar with app icon on left and add on clickListener on that ImageView try this link it may help if I am getting what you want to achieve http://stackoverflow.com/questions/24838155/set-onclick-listener-on-action-bar-title-in-android – Mrinmoy Dec 17 '16 at 08:37

1 Answers1

0

add this in activity

 ActionBar actionBar=getActionBar(); 

or if using Appcompact do

  ActionBar actionBar = getSupportActionBar();

then

   actionBar.setDisplayHomeAsUpEnabled(true);

and override this method

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        //Do stuff
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}
Ketan Ahir
  • 6,678
  • 1
  • 23
  • 45
Manohar
  • 22,116
  • 9
  • 108
  • 144