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

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" >

Want To Create An Android Application?

Validate your app idea and get a free quote.

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.

Author Bio
Amit Patolia
Amit Patolia
Designation: Android Team Lead

Amit Patolia is an Android Team Lead at Space-O Technologies. He has over 9+ years of experience in Android app development. He has guided to develop over 100 Android apps with unique features and functionalities. He also has expertise in Kotlin-based apps.