ContextMenu with footer view (to add checkbox for 'make default' option)

你离开我真会死。 提交于 2019-12-21 23:50:37

问题


Is there a standard way to add a footer to a context menu, in which I can add a checkbox to make the selected option the default one? Similar to the context menu that comes up when choosing the default home screen for example.

From the Api docs for ContextMenu I see that you can set a header view, but not a footer view. Also the setCheckable / setGroupCheckable methods don't seem to help much here.

Does this need to be done via a custom (alert) dialog? I would be wondering if nobody has yet developed such a component yet in case it's not possible through the standard SDK api. Any standalone open source component out there (beside the Android source itself)?


回答1:


The best I've come up with is using an AlertDialog

alert.getListView().addFooterView(...); and overriding it's onItemSelected method.



来源:https://stackoverflow.com/questions/4093640/contextmenu-with-footer-view-to-add-checkbox-for-make-default-option

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!