【问题标题】:display customized Phone gallery to pick multiple images显示自定义电话库以选择多个图像
【发布时间】:2015-05-20 23:42:36
【问题描述】:

我无法显示自定义手机图库。

首先,我需要在 gridview 中显示图片文件夹(例如手机图库),并且在选择任何文件夹时,它必须显示其中的图片并且应该允许多选,以便我可以选择多张图片。

可以实现吗?

如果是,该怎么做?

【问题讨论】:

  • 这当然是可以实现的,已经有应用在做(如果他们能做到,你也能做到)。 :)
  • 是的..这是可能的..但我希望你做一些 rnd 工作然后用你的代码来
  • @Fahim:我尝试了很多来了解它,但仍然没有得到我想要的。

标签: android multi-select photo-gallery


【解决方案1】:

根据您的要求,按照本教程进行操作,它会给您一些想法。

http://www.technotalkative.com/android-select-multiple-photos-from-gallery/

【讨论】:

【解决方案2】:

打开画廊:

//open gallery to choose image

    private void captureImage() {

        // Create intent to Open Image applications like Gallery, Google Photos
        Intent galleryIntent = new Intent(Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        // Start the Intent
        startActivityForResult(galleryIntent, RESULT_LOAD_IMG);

    }

当图片从图库中被选中时,会调用下面的函数,实现它来保存选中的图片。

// When Image is selected from Gallery
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        try {
            // When an Image is picked
            if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK
                    && null != data) {
                // Get the Image from data

                Uri selectedImage = data.getData();
                String[] filePathColumn = { MediaStore.Images.Media.DATA };

                // Get the cursor
                Cursor cursor = getContentResolver().query(selectedImage,
                        filePathColumn, null, null, null);
                // Move to first row
                cursor.moveToFirst();

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

                // Get the Image's file name
                String fileNameSegments[] = imgPath.split("/");
                fileName = fileNameSegments[fileNameSegments.length - 1];

                // successfully selected the image
                // launching upload activity

                tvCapturePicture.setText(fileName);

            } else {
                Toast.makeText(this, "You haven't picked any Image",
                        Toast.LENGTH_LONG).show();
            }
        } catch (Exception e) {
            Toast.makeText(this, "Something went wrong ,please try again , ",
                    Toast.LENGTH_LONG).show();
        }

    }

【讨论】:

  • 它似乎不包含文件夹作为其相应图像的父级,即第一个屏幕必须显示父级文件夹(如手机图库中的那样),然后选择其中任何一个,必须显示其图像才能进行多选。
猜你喜欢
  • 2020-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多