I am using ActionbarSherlock .
I set the title for the sherlock action bar in my java code by:
actionBar.setTitle(title);
I am wondering, how can I add event handler to the title of action bar?
I am using ActionbarSherlock .
I set the title for the sherlock action bar in my java code by:
actionBar.setTitle(title);
I am wondering, how can I add event handler to the title of action bar?
You can also set the title as an up indicator and handle that clicked as you would another menu item.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Then in handling the options selected:
public boolean onOptionsItemSelected(final MenuItem item)
{
switch (item.getItemId())
{
case android.R.id.home:
// your title was clicked!
return true;
}
}
I should caution, your title should act like it has "up" behavior. By that I mean that consider your activities like a directory structure on your favorite OS. The back button goes to the place you just were, and this title should go "up" one directory regardless of how you got there.
There is no way to add an event with the built-in title.
However, you can add your own TextView
using the setCustomView
method on which you can add a listener for click.