Showing Images in GridView

Here we create an app in Sketchware which will display the images picked using FilePicker in a GridView. And on clicking the GridView item, it will display a dialog box asking if we want to delete the image. To create such app, follow the steps given below.

1. Create a new project in Sketchware.

2. In VIEW area add a Button button1 and a LinearV linear1.

3. Add a FilePicker component picker with mime type image/*.

4. Create a number variable n, a List Map maplist, and a List String slist.

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 images.

6. In EVENT area add a new event FilePicker onFilesPicked under Component section.

7. In the event FilePicker onFilesPicked use the blocks as shown in image below, to get the path of selected images to maplist.
Then use codes to display the selected images in gridview1.
gridview1.setAdapter(new ImageAdapter(getBaseContext()));

8. Create a more block extra.

9. In the more block extra, use an add source directly block and put codes to declare a GridView gridview1, and define a BaseAdapter called ImageAdapter for the GridView.
GridView gridview1;

public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
public int getCount() {
return maplist.size();
public Object getItem(int position) {
return null;
public long getItemId(int position) {
return 0;
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams((int)(SketchwareUtil.getDip(getApplicationContext(), 150)), (int)SketchwareUtil.getDip(getApplicationContext(), 150)));
imageView.setPadding(4, 4, 4, 4);
int strokeWidth = 5;
int strokeColor = Color.BLACK; gD = new; gD.setShape(;
gD.setStroke(strokeWidth, strokeColor);
} else {
imageView = (ImageView) convertView;
try {
imageView.setImageBitmap(FileUtil.decodeSampleBitmapFromPath(maplist.get((int)position).get("image").toString(), 1024, 1024));
} catch (Exception e){
return imageView;

10. In onCreate event, use an add source directly block and put codes to define gridview1 and add it to linear1.
gridview1 = new GridView(this);
gridview1.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, GridView.LayoutParams.MATCH_PARENT));
gridview1.setNumColumns(2); gridview1.setColumnWidth(GridView.AUTO_FIT); gridview1.setVerticalSpacing(20); gridview1.setHorizontalSpacing(2); gridview1.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);


After this use another add source directly block and put codes to set OnItemClickListener for the GridView.
gridview1.setOnItemClickListener(new AdapterView.OnItemClickListener(){
public void onItemClick(AdapterView<?>, View p2, final int p3, long p4){
final AlertDialog dialog2 = new AlertDialog.Builder(MainActivity.this).create();
dialog2.setTitle("Remove this image?");
dialog2.setButton("YES", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface p1, int p2){
gridview1.setAdapter(new ImageAdapter(getBaseContext()));


7. Save and Run the project. The GridView app is ready.

Android GridView with image and text example


  1. Please check your messenger inbox and give a tutorial video.

  2. profile detail with name Wala app bana skate hai

  3. Hello sir
    How to make keyboard app?

  4. Hey sketchware please tell me how to put notifications because all videos in youtube tells me a code but when i used brings me a message saying "this conde is deprecated

  5. Sir , please help me !

    I made live TV apps from sketchware Application.. but now I am wants to change urls link from firebase .I trying many times but failed!

    Please sir help me how can do this !
    Please please please

    1. Hey brother,, how did you create live tv app using sketchware?? Can you help me??? I want to create live tv app

  6. Error:
    public void onItemClick(AdapterView, View p2, final int p3, long p4){

    Insert "..


  7. How to create an application that supports uploading and downloading images and commenting on the image. How to reduce the size of the application with millions of image content in it.

  8. Svp comment faire pour crée une application qui a accès a toute les images , photos que contient la galerie sans en avoir a faire une application gridview mais une application de galerie

  9. Error:
    public void onItemClick(AdapterView, View p2, final int p3, long p4){

    Insert "..



Post a Comment

Popular posts from this blog

Create Music Player app in Sketchware

A Flash Light App in Sketchware

Admob rewarded video Ads in Sketchware

Simple car racing android game in Sketchware

Firebase auth in Sketchware for Login Activity