Actionbar下拉式点击事件 [英] Actionbar dropdown click event

查看:149
本文介绍了Actionbar下拉式点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在actionbar中有下拉列表作为导航列表。使用 ActionBar.OnNavigationListener onNavigationItemSelected 来检测用户在actionbar下拉菜单导航列表中点击了什么项目,并且工作正常。

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.

但是,如果用户点击与当前选择的项目相同的项目,则 onNavigationItemSelected 不会调用在下拉列表中(我需要这个确切的功能行为让应用程序正常工作)

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)

所以有什么办法可以检测到在actionbar中的下拉列表的任何部分点击?

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

有没有办法在actionbar中引用下拉列表视图,然后在actionbar中的该下拉列表对象上设置onclicklistner。像我们在标准布局中使用下拉列表?

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?

推荐答案

这里的问题与任何其他Spinner相同。这里的工作条件在此明确描述:微调:onItemSelected当选择的项目保持不变时,不调用

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

但是对于ActionBar,解决方案可能有点棘手(除了当您使用ActionBarSherlock 并且可以明确地混淆其代码)

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)

这篇关于Actionbar下拉式点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆