Skip to main content

Posts

Showing posts from 2020

Featured post

Simple RecyclerView example with filter option in Android

Hi Guys, Maybe you all are expert in terms of using RecyclerView in android. This blog is simple example for using filter option with RecyclerView adapter. As for now you will instantiate RecyclerView and set the adapter to RecyclerView as following way. RecyclerView list = (RecyclerView) findViewById(R.id.list); list.setLayoutManager(new LinearLayoutManager(this)); list.setHasFixedSize(true); ArrayList&ltNumber&gt numbers = new ArrayList&lt&gt(); String ONEs[] = {"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN"}; String TENs[] = {"ZERO", "TEN", "TWENTY", "THIRTY", "FOURTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY", "HUNDRED"}; String HUNDREDS[] = {"ZERO", "HUNDRED", "TWO HUND

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 = mutableSetOf&lt