Building Two-Dimensional Scrolling List Using Android GridView in Android App

android gridview example

If you’re familiar with Android’s listview layout component, then you should feel like home here as well. The Android GridView is quite similar to listview component. It basically helps to build two-dimensional, easy-to-browse scrolling lists. You might have noticed gridviews in many apps such as Instagram, Snapchat, PayTM, which means it’s a necessary skill. And after following this tutorial step-by-step, you’ll be able to implement this layout in your native Android app.

Let’s Get Started

Create a new project under file menu, modify the project details, and choose appropriate location for the demo.

Create a new project in Android Studio

Choose Mini Support SDK to use this project.

Add a target device

Lastly, Select Add No Activity in the last tab and click on Finish button.

Select Empty Activity

Create XML File

<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android=""
android:layout_height="fill_parent" >

Create Class For MainActivity

package com.gridviewdemo;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
GridView gridView;
static final String[] numbers = new String[]{
"1", "2", "3", "4", "5",
"6", "7", "8", "9", "10",
"11", "12", "13", "14", "15",
"16", "17", "18", "19", "20"};
public void onCreate(Bundle savedInstanceState) {
gridView = (GridView) findViewById(;
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, numbers);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
((TextView) v).getText(), Toast.LENGTH_SHORT).show();

Now when you run the demo, it should look like this.


Android Gridview Example

And Done!

So now that you know the process of implementing Android Gridview in an Android app, Go Ahead and start implementing it. And in case you’re building an Android app from scratch, and you need to consult with an expert person, hire Android app development company, discuss your app idea, and build your app with the right people.

Grab a free copy of Gridview Android Example Demo from Github.

You may also like,

This page was last edited on September 14th, 2020, at 9:41.


Want to Develop Android App From Scratch? Contact Us Now

Get your free consultation now

Leave a Reply

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