向剪贴板 ActionBar 添加功能
在我的应用程序中,我希望当用户将文本复制到剪贴板时能够启动我自己的功能。
我正在重写 onActionModeFinished 函数,并且因为我想确保用户点击“复制”,所以我正在获取选定的导航索引。不幸的是如果总是返回-1。我在这里做错了什么吗?
@Override
public void onActionModeFinished(ActionMode mode) {
super.onActionModeFinished(mode);
if (_actionBar != null) {
int index = _actionBar.getSelectedNavigationIndex();
// here index is always -1
}
}
In my app, I want to be able to start my own function when user copy a text to the clipboard.
I'm overriding function onActionModeFinished and as I want to be sure user tapped on Copy I'm getting selected navigation index. Unfortunately if always return -1. Is there something I'm doing wrong here ?
@Override
public void onActionModeFinished(ActionMode mode) {
super.onActionModeFinished(mode);
if (_actionBar != null) {
int index = _actionBar.getSelectedNavigationIndex();
// here index is always -1
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ActionBar 可以在左侧包含选项卡和列表选择器。因此, getSelectedNavigationIndex 用于获取此导航项中的位置,而不是位于右侧的菜单项中的位置。
ActionBar can contain tabs and list selector on the left side. So, getSelectedNavigationIndex is used to get the position in this navigation items not in the menu items located in the right side.