隐藏contexual行动起来吧,而导航抽屉打开 [英] Hiding contexual action bar while navigation drawer is open

查看:148
本文介绍了隐藏contexual行动起来吧,而导航抽屉打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在的问题是类似<一个href="http://stackoverflow.com/questions/15019289/hiding-showing-the-contextual-action-bar-programmatically">this除了而是采用了查看传呼机(VP),我想用一个抽屉式导航(ND)的事实。我有一个激活上下文操作栏(CAB)在一个/多个项目通过长期的preSS行动所选元素的列表。当ND打开我想暂时隐藏CAB和显示基本操作栏,而当它被关闭,再次显​​示出与所选择的项目CAB。

The question is similar to this except for the fact that instead of using a View Pager (VP) I want to use a Navigation Drawer (ND). I have a list of elements that activates a Contextual Action Bar (CAB) when one/several items are selected through long press actions. When the ND is opened I want to hide temporarily the CAB and show the basic action bar, while when it is closed to show again the CAB with the selected items.

该功能在ND官方文档隐藏上下文动作条,而抽屉规定是可见的。。到目前为止,我找不到任何地方如何使它在一个不错的方式,但我想一个解决方法:

The feature is specified in the ND official documentation "Hide contextual action bars while the drawer is visible.". So far I couldn't find anywhere how to make it in a nice way, but I tried a workaround:

  • 完成CAB时ND打开并保存所选的项目(如果有的话)。
  • 当抽屉关闭,启动操作模式,使CAB和填充,从保存的列表中选择的项目列表。

什么,我想实现可以体验与Gmail应用程序的一个例子。

An example of what I am trying to achieve can be experienced with the Gmail application.

感谢您事先的任何答复!

Thank you in advance for any answer!

推荐答案

要达到这一要求,我打电话从ActionBarDrawerToggle回调方法这两个方法:

To achieve this requirement, I am calling these two methods from the ActionBarDrawerToggle callback methods:

public void onDrawerOpened() {
  if (mActionMode != null) {
    mCheckedListItems = mListView.getCheckedItemPositions().clone();
    mActionMode.finish();
  }
}
public void onDrawerClosed() {
  if (mCheckedListItems!=null) {
    for (int i=0; i<mCheckedListItems.size(); i++) {
      if (mCheckedListItems.valueAt(i)) {
        mListView.setItemChecked(mCheckedListItems.keyAt(i), true);
      }
    }
  }
  mCheckedListItems = null;
}

这篇关于隐藏contexual行动起来吧,而导航抽屉打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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