Yesterday I have written a post on Simple Grid View with single text view only. Now I am writing for the Custom Grid View having Image and Text View in each of its grid.

Adapter loads the Grid View with the data from data sources. For grid view with a single text, we used ArrayAdapter of String type. For a Grid View with more than one widgets, you need to create a Custom Adapter that is a user define Adapter that extends Predefined Adapter. Same concept I am going to use here.

  1. Create a new project File -> New -> New Project. Give a name as CustomGridView go next -> next and finish.
  2. Add some images in res-> drawable. you can simply paste any images or import default icons as File-> New-> Vector Assets -> Material Icon -> Choose-> select whichever you want and press Ok.
  3. Open activity_main.xml from res-> layout -> activity_main.xml and copy the code below in Text tab of activity_main.xml.

4. Create a single grid layout as grid_item in res-> layout-> right click ->New -> Layout resource file give a name grid_item. Copy the below code in that file.

5. Now create a java file as GridCustomAdapter and copy the below code in it.

6.Now open your MainActivity.java and copy the code below.

7. Your AndroidManifest.xml will be as below.

8. Finally, run your code,  You will have the following output.

How to create Custom Grid View in Android
How to create Custom Grid View in Android

Here we did with the Grid View with image and text in its grid in Android. Hope you found it easy and understand v. For any query comment below I will be there to solve your query.