我需要向文件浏览器添加一个菜单项,但需要是可见的图像和文档(文本文件,pdf,doc等)。
当我使用下面的代码时,当我打开文件资源管理器时,菜单项会被添加到所有文件夹中。
ApplicationDescriptor appDesc = ApplicationDescriptor.currentApplicationDescriptor();
ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_BROWSE, this,appDesc);
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_ITEM, this,appDesc);
根据API,我们可以指定MIME类型,使菜单项仅对特定文件可见。我使用下面的代码,但菜单项仅对图像可见,而不对文档类型可见。
ApplicationDescriptor appDesc = ApplicationDescriptor.currentApplicationDescriptor();
ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_BROWSE, this,appDesc,new String("image/*;text/*;application/*"));
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_ITEM, this,appDesc,new String("image/*;text/*;application/*"));
我也尝试使用下面的代码,但菜单项仍然只对图像可见,但对文档类型不可见。
ApplicationDescriptor appDesc = ApplicationDescriptor.currentApplicationDescriptor();
ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_BROWSE, this,appDesc,new String("image/*"));
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_ITEM, this,appDesc,new String("image/*"));
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_BROWSE, this,appDesc,new String("text/*"));
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_ITEM, this,appDesc,new String("text/*"));
需要帮助才能达到要求。
答案 0 :(得分:0)
ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_BROWSE,new BrowserMenuItemClass(0),ApplicationDescriptor.currentApplicationDescriptor(),"image/jpeg" );
ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_ITEM,new BrowserMenuItemClass(0),ApplicationDescriptor.currentApplicationDescriptor(),"image/jpeg" );
ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_BROWSE,new BrowserMenuItemClass(0),ApplicationDescriptor.currentApplicationDescriptor(),"image/gif" );
ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_FILE_EXPLORER_ITEM,new BrowserMenuItemClass(0),ApplicationDescriptor.currentApplicationDescriptor(),"image/gif" );