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

Sentry blog image

The countdown to March 31 is on.

Make the switch from app center suck less with Sentry.

Read more

Top comments (0)

Sentry growth stunted Image

If you are wasting time trying to track down the cause of a crash, it’s time for a better solution. Get your crash rates to zero (or close to zero as possible) with less time and effort.

Try Sentry for more visibility into crashes, better workflow tools, and customizable alerts and reporting.

Switch Tools

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay