Load data from api to recylerview using JetPack Compose

Hi today we look in to an concept of how to load data from an api using retrofit and load in to an recylerview using Jetpack Compose and single selection highlight on recylerview selection.

First we import things needed for retrofit in to our app level build gradle

We are going to create a model data class of name Movie.kt with the following variables like name,category etc

Now lets create an interface class ApiService.kt to get and return data to viewmodel

Next we are going to create ApiViewModel.kt we are launching our api call inside viewModelScope.launch so it will run as long as our viewmodel active on any failure we will be passing to our error message part.

Now comes the ui part you can see we created a item for display MovieItem function

Thats it we have our APi loaded to the recylerview.

Knowledge is everything.Check out my app at https://play.google.com/store/apps/details?id=com.vibe.britevibe

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Hailey Bieber Stuns in Skintight Latex Leggings by Saint Laurent

JPGChat: TryhackmeWriteup

Sia Community Update — November 2019

The One Simple Trick to Master Python in Just 7 Days!

Deploying an Elixir Phoenix application with Docker and Makefile

Ampleforth Update — We are Speeding up Supply Adjustments.

Barcode Generator | Opencart | Code E-Shop

Learn Python By Example: One Line Of code To install All Python Libraries

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pandiyan Mani

Pandiyan Mani

Knowledge is everything.Check out my app at https://play.google.com/store/apps/details?id=com.vibe.britevibe

More from Medium

Requesting Multiple Permissions in Jetpack Compose…

Getting prepared for Jetpack Compose

Jetpack Compose Tutorial

Expert: Integration of HMS Core Kits in Android Jetpack App Part-1

Using navigation component in ViewModels on Android(MVVM Architecture)