0
計劃爲文本(Editext,Textview)實現全局上下文菜單。需要在longpress上下文菜單中添加一個選項,如「將詞添加到詞典」
一個新的選項應該在那裏所選擇的單詞添加到我的wordcollector類型的應用程序。 如何將上述選項添加到全局上下文菜單。
計劃爲文本(Editext,Textview)實現全局上下文菜單。需要在longpress上下文菜單中添加一個選項,如「將詞添加到詞典」
一個新的選項應該在那裏所選擇的單詞添加到我的wordcollector類型的應用程序。 如何將上述選項添加到全局上下文菜單。
你可以改變應用程序的上下文菜單是這樣的:
@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]);
}
}
}
你不能改變全局上下文菜單。如果沒有執行您公開的意圖或活動的特定活動,則無法在系統級全局覆蓋或掛接功能。即使在發佈意圖的情況下,除非運行的應用程序是消費者,否則無關緊要...並且所有基礎系統應用程序和顯然所有應用程序之前的應用程序都不會更新應用程序以供使用。
感謝您的摘錄。但我需要實現一個全局上下文菜單。它應該在所有應用程序(消息,瀏覽器)中工作時選擇文本。 – Satheesh
@Satheesh檢查我更新的答案 – Pallavi
我知道從哪裏回答http://stackoverflow.com/questions/559405/android-add-item-to-global-context-menu請參閱第一個回答的最後一條評論「It是可能的,它只是不漂亮: - \ - - - - haseman 09年2月20日在23:31「 – Satheesh