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. 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
  6. Put I want to upload image gallery to edittext background

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

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

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

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

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

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

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

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

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

    ReplyDelete
  16. Hey, please what is the code to add for file pick.
    Using add source directly

    ReplyDelete
  17. This code doen't work for the New Android version.

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

    ReplyDelete
  19. how can i upload multiple images to firebase at a time and load them in listview?

    ReplyDelete
  20. I have problem with "get 0 of List String : filePath" block

    ReplyDelete
  21. How can I add image from File Shared Preferences to drawer?
    Help please

    ReplyDelete
  22. Please how can you load the images in Two's instead of 1 per list view. Let it be two per row

    ReplyDelete
  23. When I use (imageview set image from url __) app is not building.. it's exiting automatically while running the app. Please help. How to resolve it.

    ReplyDelete

Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Creating a Drawing View in Sketchware

Enable Fullscreen for Youtube videos in WebView

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware