Loading image from gallery to ImageView in Sketchware
1. In VIEW area of Sketchware project add a Button button1, and an ImageView imageview1.
2. Set an image as default image of imageview1.
3. Create a new FilePicker picker component for picking images.
4. Now create a new String List list.
5. In the event on button1 Click , use the block
FilePicker picker pick files.
This will open the gallery when button1 is clicked, and allow users to pick any image.
6. In EVENT area add a new event FilePicker onFilesPicked under Component section.
7. In the event FilePicker onFilesPicked use the blocks:
ImageView imageview1 set image from file path ....
and
get at 0 of List String : filePath
as shown in image below, to set the selected image as image of imageview1.
8. Save and Run the project. Now when the user clicks button1, he can browse through gallery and select an image. The selected image will be displayed in imageview1.
Watch the videos below.
i. Pick a single image from gallery.
ii. Pick multiple images from gallery.
Post a Comment