Grid View

GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. The grid items are automatically inserted to the layout using a ListAdapter. Project Structure: 1.MainActivity.java2.ImageAdapter.java3.main_activity.xml4.Save the image files into the project’s res/drawable/ directory.  (Download) main_activity.xml <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”    xmlns:tools=”http://schemas.android.com/tools”    android:id=”@+id/activity_main”    android:layout_width=”match_parent”    android:layout_height=”match_parent”    android:paddingBottom=”@dimen/activity_vertical_margin”    android:paddingLeft=”@dimen/activity_horizontal_margin”    android:paddingRight=”@dimen/activity_horizontal_margin”    android:paddingTop=”@dimen/activity_vertical_margin”    tools:context=”com.blogspot.csdevbin.listexample.MainActivity”>    <GridView        android:id=”@+id/gridview”        android:layout_width=”match_parent        android:layout_height=”match_parent”         android:columnWidth=”90dp”        android:numColumns=”auto_fit”        android:verticalSpacing=”10dp”        android:horizontalSpacing=”10dp”        android:stretchMode=”columnWidth”        …

Grid View Read More »