Loading​ image from gallery to ImageView in Sketchware


To load an image from gallery to an ImageView in Sketchware app, follow the steps given below.

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.


Comments

  1. Works good. But now its useless because when you close app and open it next time, an image is not saved on imageview. Would be nice to get code how to save an image permanently. Thanks,

    ReplyDelete
    Replies
    1. You can convert the Uri to String and store it in file shared preferences. And in onCreate convert the stored String to Uri, and set it as imageUri.

      Another way is to store image in app Cache.

      Delete
    2. I try but its not working, its always null return, can you write the example?

      Delete
  2. Heyyy,you're awesome.. I just ask it couple hour and voilaa.. it's done.. awesommee..
    But I think it's more awesome if we can make a dialogue wheter choose from gallery or take a picture, right?
    Can u make it?😅

    ReplyDelete
  3. Plz make a video how to save image into File SharedPreferences .

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Ciao Sanjeev faccio davvero molta fatica ad inserire un'immagine dalla mia galleria su "image manager" cosa posso fare?

    ReplyDelete
  6. Result in null i want to change backgroud of edittext how to give working result

    ReplyDelete
    Replies
    1. In properties of edittext, you can change it's background.

      Delete
  7. Put I want to upload image gallery to edittext background

    ReplyDelete
  8. It works but I want it to be opened in another page ( Exmpl- page2 ) . Can you help

    ReplyDelete
  9. And want to edit that selected picture. Plz help

    ReplyDelete
  10. im trying to allow users to add images to a gallery and would love some help

    ReplyDelete
  11. Its not work, everytime shows a transparent image, and i can't see the image that i have choosed, what can i do??

    ReplyDelete
  12. Hi please I want to make a fashion app to display more fashion pictures in different categories using sketchware. Please help me out.

    ReplyDelete
  13. Ayuda quiero subir imagenes para compartir con el público, pero que sea de forma permanente. Seria de gran ayuda un video. Gracias.

    ReplyDelete
  14. Hello. How to pick an image to set background linear directly ? It's possible? Thanks.

    ReplyDelete
  15. The path uri cannot contain path elements error
    How can I solve this problem?

    ReplyDelete
  16. Hello. How do you do this from linear1?

    ReplyDelete

Post a Comment

Popular posts from this blog

A Flash Light App in Sketchware

Create Music Player app in Sketchware

In Sketchware: How to create a calculator for any simple formula?

Simple car racing android game in Sketchware

Firebase auth in Sketchware for Login Activity