Posts

Showing posts from April, 2025

Android Activity Lifecycle

Image
  What is the Android Lifecycle? The Android Activity Lifecycle defines how an activity behaves in different states: - Created - Started - Resumed - Paused - Stopped - Destroyed Lifecycle Methods • onCreate(): Initialize your activity • onStart(): Activity is about to become visible • onResume(): Activity has become visible • onPause(): Partially obscured • onStop(): Fully obscured • onRestart(): Restarting after stop • onDestroy(): Cleanup before destruction JAVA CODE    @Override         protected   void  onCreate(Bundle savedInstanceState) {            super .onCreate(savedInstanceState);           setContentView(R.layout.activity_main);           Log.d( "lifecycle" , "onCreate invoked" );       }        @Ove...

Recycler View: MarketApp

Image
 Recycler View: MarketApp 📋 Steps to Create a RecyclerView: Item Layout: First, design the layout for a single item in XML. This layout defines how each row/item in the RecyclerView will look. RecyclerView Widget: Add the RecyclerView in your activity's layout and initialize it in the activity or fragment using Java/Kotlin code. Model Class: Create a data class that holds the information for each item (like title, image, etc.) you want to show in the RecyclerView. Adapter Class: This is where the real action happens. The adapter connects the data (from the model) to the views (item layout). It handles creating item views and binding data to them. ViewHolder: ViewHolder holds references to the views inside each item, making scrolling smooth and fast by avoiding repeated findViewById calls Resources :   https://drive.google.com/drive/folders/1vp4TVMTACXblVQM-HGPc1UrqWZoAoRV6?usp=drive_link Item Layout android:layout_height="wrap_content">     ...