如何选择多张图片从画廊?画廊、如何选择、多张、图片

2023-09-06 23:05:01 作者:花自己的钱,才能花的风光!走自己的路,才能走到远方!今日小编

我想从文件的位置选择多张图像。到目前为止,我已经成功地选择一个图像,但我怎么能选择两个图像组合在一起。

 意向意图=新的意图(Intent.ACTION_PICK);
                intent.setType(图像/ *);
                startActivityForResult(意向,STEP_4_REQUEST);
 

然后在 onActivityResult(INT申请code,INT结果code,意图数据)方法如下:

 案例STEP_4_REQUEST:
            如果(结果code == RESULT_OK){
                乌里selectedImage = data.getData();
                的String [] filePathColumn = {MediaStore.Images.Media.DATA};

                光标光标= getContentResolver()查询(selectedImage,
                        filePathColumn,NULL,NULL,NULL);
                cursor.moveToFirst();

                INT参数:columnIndex = cursor.getColumnIndex(filePathColumn [0]);
                字符串文件路径= cursor.getString(参数:columnIndex);
                cursor.close();

                位图yourSelectedImage = BitmapFactory.de codeFILE(文件路径);
            }
 

解决方案

试了很多办法,最简单,最强大的是: https://github.com/luminousman/MultipleImagePick

画廊图片

I am trying to select multiple images from a file location. So far I have managed to select one image but how can I select two images together.

Intent intent =new Intent(Intent.ACTION_PICK);
                intent.setType("image/*");
                startActivityForResult(intent, STEP_4_REQUEST);

Then in the onActivityResult(int requestCode, int resultCode, Intent data) method the following:

case STEP_4_REQUEST:
            if (resultCode == RESULT_OK) {
                Uri selectedImage = data.getData();
                String[] filePathColumn = { MediaStore.Images.Media.DATA };

                Cursor cursor = getContentResolver().query(selectedImage,
                        filePathColumn, null, null, null);
                cursor.moveToFirst();

                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                String filePath = cursor.getString(columnIndex);
                cursor.close();

                Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath);
            } 

解决方案

Tried many alternatives, easiest and most robust was: https://github.com/luminousman/MultipleImagePick