Skip to main content

Posts

Showing posts from June, 2020

Exploring LayoutInflater#inflate method | Android | V4ALL

Good day!!! As a Android developer we all have experienced LayoutInflater#inflate at some point. But we maynot know clearly what this function will do. Come on, stay attention, Let's explore this in this blog with simple examples!!! Let's assume you have a layout named fragment_first.xml as following &lt?xml version="1.0" encoding="utf-8"?&gt &ltandroidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".FirstFragment"&gt &ltTextView android:id="@+id/textView" style="@style/TextAppearance.MaterialComponents.Headline4" android:layout_width="wrap_content" ...

Exploring Kotlin's LiveData | Part I | Android | V4ALL

Good day!!! As Per  Android Developer  documentation,  LiveData  is an observable data holder class. Unlike a regular observable, LiveData is lifecycle-aware, meaning it respects the lifecycle of other app components, such as activities, fragments, or services. This awareness ensures LiveData only updates app component observers that are in an active lifecycle state. Let's explore this statement with an simple example. Create our own observer which notifies if any changes available in an  username . Create a Basic Application in Android Studio using File → New → New Project and Choose Basic Activity template. [I used Android Studio 4.0] , and finish project setup. Create a kotlin file and name it as UserModel.kt and copy paste following codes, package com.example.basicapplication interface UserObserver { fun onUsernameChanged(username: String) } object UserHolder { private var username: String = "" private val userObservers...