How to select multiple images from gallery in android?

前端 未结 9 1866
無奈伤痛
無奈伤痛 2020-11-27 14:48

I am making a project in which i want to select multiple photos from gallery and want to save that in imageview array. I am able to import single image and save at imageview

9条回答
  •  一向
    一向 (楼主)
    2020-11-27 15:11

    There is EXTRA_ALLOW_MULTIPLE option is set on the intent through the Intent.putExtra() method:

      intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    

    In your code write as below:

    Intent intent = new Intent();
    intent.setType("image/*");
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent,"Select Picture"), RESULT_LOAD_IMAGE1);
    

    Note: the EXTRA_ALLOW_MULTIPLE option is only available in Android API 18 and higher.

    If you want to develop your own gallery then check out the Select Multiple Images from Gallery

提交回复
热议问题