本文介绍了如何选择多张图片从画廊?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 意向意图=新的意图(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

这篇关于如何选择多张图片从画廊?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 05:32