In this article, we will explore some common UI components that can be used while developing an application using Jetpack Compose.

Jetpack Compose is the declarative UI approach in native Android app development. It is currently in the pre-alpha stage. This article is the continuation of my previous article.

In Jetpack compose we can build a beautiful layout in a few minutes. It is based on material design principles and provides material design components out of the box.

Compose is built to support material design principles. Many of its UI elements implement material design out of the box.

Note: Updated…

You might have already heard about Declarative UI with the rise in popularity of Flutter and SwiftUI. Jetpack Compose is the declarative UI approach in native Android app development.

Jetpack Compose was revealed in Google IO 2019. It is still in the development phase and developer preview is available at this time. Many improvements have been made since its launch. It is too early to use in production before the beta version is available. But for early adopters, it is very hard to ignore.

Note: Updated for Android Studio 4.2 Canary 2 and Jetpack Compose Version 0.1.0-dev14

Why Jetpack Compose…

In Android, SharedPrefences had always been favorite to store small data but sometimes big too, in a JSON string format.

Today I am going to simplify the data storing and retrieving method via
SharedPreferences in Kotlin way.

Let's start by observing some examples to store/retrieve data from shared preferences.

// get stored value
val myString = prefs.myString
// store value
prefs.myString = "My String Value"
// get stored array
val myStringArray = prefs.myStringArray
// store array
prefs.myStringArray = arrayOf("String 1","String 2","String 3")
// store value
prefs.myObject = MyObject("hello")
// retrieve my object
val myObject : MyObject? = prefs.myObject

First, we…

Recently from a few months my medium feed is populated with almost all featured stories like in the screenshots below:

Image for post
Image for post

The simplest mistake while writing the toolbar cost me few days.

Image for post
Image for post
image source :

Make mistakes. Learn from them. Move on. So here goes my first medium post from the mistake I made.

What I did is I wrote following XML code.


Q. What happened after this?
A. I could not set title of the activity by using setTitle(value) , neither this setTitle(R.string.value). Since I was starting to play with Kotlin, I thought I might have missed something on the code in activity but problem was different.

Q. Actually what was wrong?
A. The line app:title="@string/app_name" always set the toolbar title to the R.string.app_name and this could not be overridden by any means.

Now what I learn from this mistake is that “Never set the toolbar title in XML code”.

Sagar Chapagain

Mobile App Developer

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