Time for action - creating the fruit icon
In order to display the various types of fruits as icons, we will need to create a layout XML file. Each icon in the
GridView will be represented as an instance of this layout, in exactly the same way as list items are represented in a
ListView. We create each item as an
ImageView for the icon, with a
TextView below it for the label.
- Create a file in the
- Declare the root element of the icon as a vertical
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent">
- Create the
ImageViewelement that will serve as our icon:
<ImageView android:id="@+id/icon" ...