Android how to make clickable logo icon in action bar?

I am using SherlockActionBar for my application. In my manifest, I define an icon for the logo and launch.

android:icon="@drawable/ic_launcher" 

How to make it clickable and handle its click event? I want to return to my toolbar by clicking on the logo.

+6
source share
2 answers

Using

 actionBar.setDisplayHomeAsUpEnabled(true); 

from

 @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: //Do stuff return true; default: return super.onOptionsItemSelected(item); } } 
+30
source

Learn more about the home button here http://developer.android.com/guide/topics/ui/actionbar.html#Home

It explains how to clear the previous stack of previous actions and a few more links to the best navigation practices using the home button.

0
source

Source: https://habr.com/ru/post/918073/


All Articles