Android GridView Example Tutorial

Insert multiple images in GridView using string url array dynamically.

GridView is a type of 2-d image showing view basically used to display images on android mobile activity screen. GridView display images into Thumbnail view because it can show multiple images at single time with automatically scroll view inserted ability. On my this tutorial i am showing images on GridView using string images hold url array and with the use of list adapter inserting the images into grid view format. So here is the complete step by step tutorial for Android GridView Example Tutorial.


Android GridView Example Tutorial

Android GridView Example Tutorial.

Put all the images you want to show on gridView in drawable-hdpi folder.

paste images here
Code for file.


import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class MainActivity extends Activity {

 // ALL IMAGES drawable-hdpi folder path with image name.
 Integer[] DisplayImagesList = {, R.drawable.two, R.drawable.three, R.drawable.four, R.drawable.five
 , R.drawable.six};
 GridView GridViewDisplay;
 protected void onCreate(Bundle savedInstanceState) 
 GridViewDisplay = (GridView)findViewById(;
 // Setting up Image adapter on gridview.
 GridViewDisplay.setAdapter(new ImageAdapter(this));

 private class ImageAdapter extends BaseAdapter
 Context context;
 public ImageAdapter(Context context) 
 this.context = context;
 public int getCount() 
 return DisplayImagesList.length;

 public Object getItem(int position) 
 return DisplayImagesList[position];

 public long getItemId(int position) 
 return position;

 public View getView(int position, View convertView, ViewGroup parent) 
 //Create new image view on GridView to display images.
 ImageView imageView = new ImageView(this.context);
 //Setting up images position so images can call one by one. 
 imageView.setLayoutParams(new GridView.LayoutParams(200, 150));
 return imageView;

Code for activity_main.xml layout file.

 <RelativeLayout xmlns:android=""
 tools:context="" >

 android:numColumns="3" >



gridview Including Images

Click Here To Download Android GridView Example Tutorial project.

Leave a Reply

Your email address will not be published. Required fields are marked *