GridView


 

  1. Static GridView
  2. Dynamic GridView
  3. Static GridView with Custom ArrayAdapter
  4. Dynamic GridView with Custom ArrayAdapter
  5. Adding RunTime Values In GridView
  6. Multiselection In GridView

 

1. Static GridView
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

gridview_normalarray

Download_button

 

2. Dynamic GridView
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open src -> package -> MainActivity.java and add following code :

Step 3 : Open AndroidManifest.xml and add following code :

ScreenShot:

dy_gridview dy_gridview2

Download_button

 

3. Static GridView with Custom ArrayAdapter
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open res -> layout ->create new gridview_row.xml and add following code :

Step 4 : Open src -> package -> MainActivity.java and add following code :

Step 5 : Open src -> package ->Create new GridviewCustomAdapter.java and add following code :

Step 6 : Open AndroidManifest.xml and add following code :

ScreenShot:

gridview_custarray gridlayout2

Download_button

 

4. Dynamic GridView with Custom ArrayAdapter
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout ->Create new gridview_row.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package ->Create new GridviewCustomAdapter.java and add following code :

Step 5 : Open AndroidManifest.xml and add following code :

ScreenShot:

dy_gridview_custom dy_gridview_custom2

Download_button

 

5. Adding RunTime Values In GridView
Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.
Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open AndroidManifest.xml and add following code :

ScreenShot:

gridview_runvalues gridview_runvalues2 gridview_runvalues3 gridview_runvalues4

Download_button

 

6. Multiselection In GridView

Step 1 : Select File -> New -> Project -> Android Application Project. Fill the forms, create “Blank Activity” and click “Finish” button.

Step 2 : Open res -> layout -> activity_main.xml and add following code :

Step 3 : Open src -> package -> MainActivity.java and add following code :

Step 4 : Open src -> package -> Create new xml, gridview_row.xml and add following code :

Step 5 : Open src -> package -> Create new class, GridViewCustomAdapter.java and add following code :

Step 6 : Open AndroidManifest.xml and add following code :

Step 7 : Open build.gradle(Module: app) and add following code :

ScreenShot:

gridview_multiselectiongridview_multiselection

Download SourceCode