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.
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,
ReplyDeleteYou 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.
DeleteAnother way is to store image in app Cache.
I try but its not working, its always null return, can you write the example?
DeleteHeyyy,you're awesome.. I just ask it couple hour and voilaa.. it's done.. awesommee..
ReplyDeleteBut 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?😅
Plz make a video how to save image into File SharedPreferences .
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteResult in null i want to change backgroud of edittext how to give working result
ReplyDeleteIn properties of edittext, you can change it's background.
DeletePut I want to upload image gallery to edittext background
ReplyDelete?
ReplyDeleteIt works but I want it to be opened in another page ( Exmpl- page2 ) . Can you help
ReplyDeleteAnd want to edit that selected picture. Plz help
ReplyDeleteim trying to allow users to add images to a gallery and would love some help
ReplyDeleteIts not work, everytime shows a transparent image, and i can't see the image that i have choosed, what can i do??
ReplyDeleteHi please I want to make a fashion app to display more fashion pictures in different categories using sketchware. Please help me out.
ReplyDeleteAyuda quiero subir imagenes para compartir con el público, pero que sea de forma permanente. Seria de gran ayuda un video. Gracias.
ReplyDeleteHello. How to pick an image to set background linear directly ? It's possible? Thanks.
ReplyDeleteThe path uri cannot contain path elements error
ReplyDeleteHow can I solve this problem?
Hello. How do you do this from linear1?
ReplyDeleteHey, please what is the code to add for file pick.
ReplyDeleteUsing add source directly
This code doen't work for the New Android version.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletehow can i upload multiple images to firebase at a time and load them in listview?
ReplyDeleteI have problem with "get 0 of List String : filePath" block
ReplyDeleteHow can I add image from File Shared Preferences to drawer?
ReplyDeleteHelp please
Please how can you load the images in Two's instead of 1 per list view. Let it be two per row
ReplyDeleteLike two horizontally
ReplyDeleteWhen 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