Posts

RadioButton in Android

  Android RadioButton RadioButton  is a two states button which is either checked or unchecked. If a single radio button is unchecked, we can click it to make checked radio button. Once a radio button is checked, it cannot be marked as unchecked by user. RadioButton is generally used with  RadioGroup . RadioGroup contains several radio buttons, marking one radio button as checked makes all other radio buttons as unchecked. Example of Radio Button In this example, we are going to implement single radio button separately as well as radio button in  RadioGroup . activity_main.xml File: activity_main.xml <? xml   version = "1.0"   encoding = "utf-8" ?>    < LinearLayout         xmlns:android = "http://schemas.android.com/apk/res/android"         xmlns:tools = "http://schemas.android.com/tools"         android:layout_width = "match_parent"         android:layout_height = "match_parent"         android:orientation = "v

GRIDVIEW IN ANDROID

  A GridView is a type of AdapterView that displays items in a two-dimensional scrolling grid . Step 1: Create a New Project in Android Studio To create a new project in Android Studio please refer to  How to Create/Start a New Project in Android Studio . The code for that has been given in both  Java and Kotlin Programming Language for Android. Working with the XML Files Next, go to the  activity_main.xml file , which represents the UI of the project. Below is the code for the  activity_main.xml  file. Comments are added inside the code to understand the code in more detail.   <? xml version ="1.0" encoding ="utf-8"?> < androidx.constraintlayout.widget.ConstraintLayout xmlns:android =" http://schemas.android.com/apk/res/android "      xmlns:tools =" http://schemas.android.com/tools "      android:layout_width ="match_parent"      android:layout_height ="match_parent"      tools:context ="