Actionbar dropdown click event

家住魔仙堡 提交于 2019-12-12 07:48:26

问题


I have dropdown list in actionbar as navigation list. Using ActionBar.OnNavigationListener and onNavigationItemSelected to detect when user has clicked on item in actionbar dropdown navigation list and that works fine.

However, onNavigationItemSelected is not called if user has clicked on the same item as the one which is currently selected in dropdown list! (I need this exact functionality behavior for app to work properly)

So is there any way to detect click on any part of the dropdown list in actionbar?

Is there a way to somehow reference dropdown view in actionbar, and then set onclicklistner on that dropdown object in actionbar. Like when we use dropdown list in standard layout?


回答1:


The problem here is the same as with any other Spinner. The workariund for this is clearly described here: Spinner : onItemSelected not called when selected item remains the same

However for the ActionBar the solution can be a bit tricky (except for when you are using the ActionBarSherlock and can explicitly mess with its code)



来源:https://stackoverflow.com/questions/12635982/actionbar-dropdown-click-event

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