Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个存储在变量“首选项”中的首选项:
Preference preference = new Preference(this);
我想添加一个上下文菜单以在longclick上显示。我已经创建了菜单/res/menu/pref_menu.xml并尝试过registerForContextMenu(preference);,但它只适用于视图。我怎样才能优先实现它?
/res/menu/pref_menu.xml
registerForContextMenu(preference);
我通过在 onPostCreate 方法中注册解决了它:
registerForContextMenu(getListView());
并在需要打开时设置一定的偏好点击监听器:
openContextMenu(getListView());