ActionbarSherlock:标题上的事件处理程序
我正在使用 ActionbarSherlock 。
我在 java 代码中设置了 sherlock 操作栏的标题:
actionBar.setTitle(title);
我想知道,如何将事件处理程序添加到操作栏的标题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无法添加具有内置标题的事件。
但是,您可以使用
setCustomView
方法添加自己的TextView
,您可以在该方法上添加点击侦听器。There is no way to add an event with the built-in title.
However, you can add your own
TextView
using thesetCustomView
method on which you can add a listener for click.您还可以将标题设置为向上指示器,并像处理其他菜单项一样处理单击事件。
然后在处理所选选项时:
我应该注意,您的标题应该表现得像具有“向上”行为。我的意思是,将您的活动视为您最喜欢的操作系统上的目录结构。后退按钮将转到您刚才所在的位置,并且无论您如何到达那里,该标题都应该“向上”一个目录。
You can also set the title as an up indicator and handle that clicked as you would another menu item.
Then in handling the options selected:
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.