Single Choice Dialog with Jetpack Compose

Rooparsh Kalia
2 min readOct 11, 2020

--

Hey, Folks, 👋🏻 I am back again with a brand new topic to discuss with you. This time we will be building a country picker with Jetpack Compose UI Toolkit.

Jetpack Compose is Android’s modern toolkit for building native UI. It simplifies and accelerates UI development on Android. Quickly bring your app to life with less code, powerful tools, and intuitive Kotlin APIs. — Android Team

Note : It is to be kept in mind that Compose is a work in progress framework, so its APIs are skeptical to change when in production. 🚧

At the time of writing this article, the version of Jetpack Compose that we are going to use is: 1.0.0-alpha04

The final version that we are going to build is gonna look like

Country Picker Dialog

Let’s start first by creating a dialog.

The hard part of creating the UI is done. Now let’s prepare the data. 👨‍🔧

For this, we are gonna need the list of countries and their associated ISO country codes. We can create the countries list with the help of the Locale class only. No need for searching over the internet and creating a static list.

Now let’s inflate our dialog and see the magic of compose.

And that’s it. You have created a simple yet elegant Single Choice Country Picker dialog, right from scratch in no time. 🎉🎉🎉🎉

Leave a comment for any doubt or follow me on twitter for more updates or queries.

Keep supporting guys, will be back soon with another topic to discuss.

Keep Learning. Keep Growing.

--

--

Rooparsh Kalia

Software Engineer trying to swim in the ocean of technology