【发布时间】:2012-05-15 10:52:45
【问题描述】:
计划实现文本的全局上下文菜单(Editext,Textview)。
应该有一个新选项将所选单词添加到我的 wordcollector 类型的应用程序中。 如何将上述选项添加到全局上下文菜单。
【问题讨论】:
标签: android contextmenu long-press
计划实现文本的全局上下文菜单(Editext,Textview)。
应该有一个新选项将所选单词添加到我的 wordcollector 类型的应用程序中。 如何将上述选项添加到全局上下文菜单。
【问题讨论】:
标签: android contextmenu long-press
您可以像这样更改应用程序的上下文菜单:
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
if (v.getId()==R.id.list) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
menu.setHeaderTitle("EditText");
String[] menuItems = //your menu item. you can add the "add word to dictionary" as an item here.
for (int i = 0; i<menuItems.length; i++) {
menu.add(Menu.NONE, i, i, menuItems[i]);
}
}
}
您无法更改全局上下文菜单。如果特定活动没有实现您公开的意图或活动,则无法在系统级别全局覆盖或挂钩功能。即使在发布意图的情况下,除非运行的应用程序是消费者,否则所有基本系统应用程序以及显然在您之前的所有应用程序都不会在不更新应用程序的情况下使用。
【讨论】: