DEV Community

loizenai
loizenai

Posted on

Kotlin GridView example: Show Item Details | Android

https://grokonez.com/android/kotlin-gridview-example-show-item-details-android

Kotlin GridView example: Show Item Details | Android

In previous post, we had known how to show list of Items using GridView. This tutorial shows you way to implement onClick Event on Item and come into its details.

Related Post: Kotlin ListView example | Android

I. Technologies

  • Android Studio 3
  • Kotlin 1.1.51

    II. Overview

    1. Goal

    We will build an example that uses GridView to show list of food items like this: kotlin-gridview-goal

When clicking on any Item, we can go to its details in new Activity:
kotlin-gridview-show-details-goal

2. Project Structure

kotlin-gridview-show-details-structure

In this example, we add FoodDetails Activity class. Clicking on any Item in MainActivity will direct us to FoodDetails (with image, name, description).

III. Practice

1. Set up Project

  • Create New Project:
    kotlin-gridview-create-project

  • Add each item insides sample_images to res/drawable folder.

  • Add FoodDetails Activity:
    kotlin-gridview-add-activity-details

    2. Layout

    2.1 Container Layout

    Open res/layout/activity_main.xml file:

More at:

https://grokonez.com/android/kotlin-gridview-example-show-item-details-android

Kotlin GridView example: Show Item Details | Android

Top comments (0)