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 preference = new Preference(this);
ロングクリックで表示されるコンテキストメニューを追加したい。すでにメニュー/res/menu/pref_menu.xmlを作成して試しregisterForContextMenu(preference);ましたが、ビューでのみ機能します。どうすれば好みで実装できますか?
/res/menu/pref_menu.xml
registerForContextMenu(preference);
onPostCreate メソッドに登録して解決しました:
registerForContextMenu(getListView());
開く必要がある場合は、特定の設定のクリック リスナーを設定します。
openContextMenu(getListView());