1
@Override
public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Selection Options");
menu.add(0, v.getId(), 0, "Remove");
}
我希望我的菜單說「刪除AAPL」如何在android中創建動態上下文菜單?
我會從我的陣列適配器字符串AAPL,但我不知道我怎樣才能從這種方法來訪問我的數組適配器指數。
= AdapterContextMenuInfo(AdapterContextMenuInfo)menuInfo; //無法解決...你能告訴我如何正確投射它嗎? – 2010-09-02 23:34:37
@Sheehan Alam:它不是'AdapterContextMenuInfo'。它是'AdapterView.AdapterContextMenuInfo'。看到這個示例項目:http://github.com/commonsguy/cw-android/tree/master/Database/Constants/ – CommonsWare 2010-09-02 23:45:02
該示例僅適用於ContextContextItemSelected,我正在做類似的事情。如何爲onCreateContextMenu?我無法投出ContextMenuInfo ... – 2010-09-03 00:08:38