Is there a form for which you need to add several images in order to save them in an external database?

Screenshot

How to implement the selection of several images correctly (maybe the image window could be like pages and these pages could be turned over)?

  • Found as an option imageSwitcher - Yaroslav Volodymyrovich

1 answer 1

You need to run an Intent about this sort:

 final Intent intent = new Intent(Intent.ACTION_GETN_CONTENT); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.setType("image/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); 

And process in onActivityResult like this:

 ArrayList<String> fileUris=new ArrayList<>(); //массив для хранения URI возвращенных файлов if(intent.getData()==null) { //detecting multiple selection ClipData clipdata = null; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { clipdata = intent.getClipData(); for (int i=0; clipdata!=null && i < clipdata.getItemCount(); i++) fileUris.add(clipdata.getItemAt(i).getUri().toString()); } else fileUris.add(intent.getData().toString()); } else { //single selection fileUris.add(intent.getData().toString()); } 

Intent will launch the file selector built into the device (if there is, of course). If not, then you can use the aFileChooser project

  • That is not, in my opinion it is not convenient, it is more convenient to click on the thumbnail of the image, as in the screenshot, take a picture and make the picture go to the thumbnail, and then scroll to another blank thumbnail and similarly take a picture for the new thumbnail. I would like to realize something like that ... - Yaroslav Volodymyrovich