操作栏福尔摩斯行动项目视图 [英] Action Bar Sherlock action item view

查看:106
本文介绍了操作栏福尔摩斯行动项目视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示点击动作栏项目后,迅速采取行动,所以我 需要得到父母为了知道哪里应该迅速采取行动 如图所示。

I am trying to show quick action after click on action bar item, so I need to get a parent view to to know where should be quick action shown.

下面是我的code:

@Override 
public boolean onCreateOptionsMenu(final Menu menu) { 
   prepareQuickActions();

   MenuItem menuItem = menu.add("Text"); 
   menuItem.setIcon(R.drawable.ic_action_dialog_map) 
           .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

   menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { 
       @Override 
       public boolean onMenuItemClick(final MenuItem item) { 
           quickAction.show(item.getActionView()); 
           return true; 
       } 
   }); 
}

问题是, item.getActionView()返回null。凡可能是一个 问题?错误在图书馆?

Problem is that item.getActionView() returns null. Where could be a problem? Bug in a library?

推荐答案

通过一个菜单项的默认操作观点是空,因为它只是有点,您可以使用自定义替代。据我所知是没有办法去的菜单项的观点。一种解决方法,我知道会是你希望它是什么样子率先成立的动作视图(你可以风格它任何你喜欢的方式),然后它不会返回null ...

By default action view of a MenuItem is null because it is just sort of an alternative that you can use to customize. As far as I know there is no way to get to the view of the MenuItem. A workaround I know would be to set the action view first to what you want it to look like (and you can style it any way you like) and then it wont return null ...

另请参见<一href="http://stackoverflow.com/questions/8598015/different-look-style-for-specific-menu-item-on-actionbar">Different查找/样式指定菜单项上的动作条

这篇关于操作栏福尔摩斯行动项目视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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