A Grid view in android is generally used to  represent data in form of grids, i.e., rows and columns, in list view we can display any number of rows but when it comes to displaying both rows and columns we use grid view.

Generally in gallery we see grid views and shopping apps where products are shown using a grid view And again we can use make a customized grid view where we can place a simple image or image with text and description so on…

In this tutorial i will be showing a Grid View with and image view and simple description  text.

grid

 

Now let’s start making our First Activity

Adding images and description in form of string array’s so that this will get displayed  in form of grid view.

 

MainActivity.java

activity_main.xml

 

Now design grid view i.e., what are the components to be displayed in list view i am using a image view and and one text view.

layout_grid.xml

 

Creating a GridViewAdapter :

Here comes our GridViewAdapter where we can set the data into grid view.

GridViewAdapter.java

 

Output 

gridview

Any queries in above tutorial post your comments.

Like and share this tutorial if you like it.

Show Buttons
Hide Buttons
Read previous post:
Android Login And Registration based on MYSQL Database using php Part 2.

Close