Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codenameone 在Android上,Display.getInstance().openGallery()不允许多重选择_Codenameone - Fatal编程技术网

Codenameone 在Android上,Display.getInstance().openGallery()不允许多重选择

Codenameone 在Android上,Display.getInstance().openGallery()不允许多重选择,codenameone,Codenameone,下面的代码允许在iOS和emulator上选择多个图像。在Android上,Gallery窗口打开,但只能选择一个图像-即使您长按。如果您手动打开Gallery(在codenameone应用程序之外),则可以进行多项选择 Display.getInstance().openGallery((e) -> { if(e != null && e.getSource() != null) { String[] files = (String[])e.get

下面的代码允许在iOS和emulator上选择多个图像。在Android上,Gallery窗口打开,但只能选择一个图像-即使您长按。如果您手动打开Gallery(在codenameone应用程序之外),则可以进行多项选择

Display.getInstance().openGallery((e) -> {
    if(e != null && e.getSource() != null) {
        String[] files = (String[])e.getSource();

        String filenames = "";
        for (int i=0; i < files.length; i++) {
            filenames = filenames + files[i] + "|";
        }
        System.out.println("selected filenames:" + filenames);
    }
},  CN1Constants.GALLERY_ALL_MULTI);

返回true

这是Androids意图系统的一个限制。当您第一次从图库中选择时,它会提示您选择图库应用程序的选项。一些多媒体资料应用程序不支持多选

您可以从系统设置中清除应用程序的关联,以再次触发该提示。然后选择一个可能解决该问题的不同应用程序

不幸的是,由于Android的工作方式,这是唯一合理的解决办法

isGalleryTypeSupported(CN1Constants.GALLERY_ALL_MULTI)