Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android how to make clickable logo icon in actionbar?

I`m using SherlockActionBar for my application. In my manifest I define icon for logo and launch.

    android:icon="@drawable/ic_launcher"

How to make it clickable and handle the event of it`s pressing? I want to be able to back to my dashboard by pressing the logo.

like image 415
Stas Avatar asked Jun 14 '12 09:06

Stas


1 Answers

Use

actionBar.setDisplayHomeAsUpEnabled(true);

with

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        //Do stuff
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}
like image 53
nhaarman Avatar answered Sep 27 '22 22:09

nhaarman