0

I would like to select multiple images and display these images into different separate ImageViews. I select a multiple images, but it shows the same image view. Please help I'm really stuck.

For Example. if the user selects 2 pic direct set into imageview 1 and imageview 2

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"), REQUEST_BROWSE_PICTURE);

 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (resultCode == RESULT_OK) {

            if (requestCode == REQUEST_BROWSE_PICTURE){
                if (data.getData() != null) {
                    Uri selectedImage = data.getData();
                    ivImage1.setImageURI(null);
                    ivImage1.setImageURI(selectedImage);

                }
            }
        }
    }
ziza
  • 1

2 Answers2

1

First try to get all images data.getClipData - check out this answer

store this to an arraylist for Recyclerview

Show selected image

create multiple image views instead of single one. ivImage1, ivImage2 etc or use Images in RecyclerView

Community
  • 1
  • 1
Adarsh Vijayan P
  • 2,964
  • 2
  • 16
  • 27
0

Get all Uris:

ClipData clip = data.getClipData();

for(int i = 0; i < clip.getItemCount(); i++) {
    ClipData.Item item = clip.getItemAt(i);
    Uri uri = item.getUri();
    urilist.add(uri);
}

Then pass the urilist to a listView or recyclerView adapter.

hyhashemi
  • 43
  • 4