I have a requirement where i have a icon ( not the application icon ) that needs to be on left hand side of the action bar.
I tried creating custom view but i have no clue on how to detect the click on that icon.
Other option that comes to mind is to have setIcon(mycustomicon) and handle the click events onOptionSelected method; but this method is also not being invoked and not working.
I am using actionbar sherlockholmes library. Is it because of that?
Please help me as i am stuck with this for days .
Thanks in advance
If you are adding your custom view with
getSupportActionBar().setCustomView(resId), you need to get the newly created View object back by callinggetSupportActionBar().getCustomView(). Then, you can set your click handler withsetOnClickListeneras you would normally do with others views.On the other hand, if you are using one of the overloads of setCustomView that take a View as the first parameter, the first step can be omitted since you already have a View object to work with.
Here is an example for the first case: