SlideShare a Scribd company logo
2
Most read
4
Most read
5
Most read
Android App with Radio button group – NITHIYAPRIYA PASAVARAJ
Android Application with Radio Button
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/lnrlayout"
android:layout_width="fill_parent"
android:layout_height="756dp"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
Android App with Radio button group – NITHIYAPRIYA PASAVARAJ
android:layout_width="wrap_content"
android:layout_height="72dp"
android:text="Select Your Favorite Color"
android:textColor="#7B1FA2"
android:textSize="30sp"
android:textStyle="bold"
tools:layout_conversion_absoluteHeight="61dp"
tools:layout_conversion_absoluteWidth="388dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp" />
<RadioGroup
android:layout_width="355dp"
android:layout_height="397dp">
<RadioButton
android:id="@+id/clrred"
android:layout_width="match_parent"
android:layout_height="47dp"
android:layout_weight="1"
android:checked="false"
android:text="Red"
android:textAllCaps="true"
android:textColor="#E64A19"
android:textSize="24sp"
android:textStyle="bold|italic" />
<RadioButton
android:id="@+id/clrblue"
android:layout_width="match_parent"
android:layout_height="43dp"
android:layout_weight="1"
android:checked="false"
android:text="Blue"
android:textAllCaps="true"
android:textColor="#512DA8"
android:textSize="24sp"
android:textStyle="bold|italic" />
<RadioButton
android:id="@+id/clrgreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
Android App with Radio button group – NITHIYAPRIYA PASAVARAJ
android:layout_weight="1"
android:text="Green"
android:textAllCaps="true"
android:textColor="#00796B"
android:textSize="24sp"
android:textStyle="bold|italic" />
<RadioButton
android:id="@+id/clryellow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Yellow"
android:textAllCaps="true"
android:textColor="#FBC02D"
android:textSize="24sp"
android:textStyle="bold|italic" />
<RadioButton
android:id="@+id/clrorange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Gray"
android:textAllCaps="true"
android:textColor="#A3A39F"
android:textSize="24sp"
android:textStyle="bold|italic" />
</RadioGroup>
<Button
android:id="@+id/btnsubmit"
android:layout_width="180dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:background="#9DC218"
android:text="Submit"
android:textAllCaps="true"
android:textColor="#7B1FA2"
android:textSize="30sp"
android:textStyle="bold" />
Android App with Radio button group – NITHIYAPRIYA PASAVARAJ
<TextView
android:id="@+id/txtview"
android:layout_width="match_parent"
android:layout_height="132dp"
android:textSize="30sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
Mainactivity.java
package com.example.radiobtngrp;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
RadioButton red,blue,green,yellow,orange;
Button btnsubmit;
TextView txtview;
LinearLayout lnrlayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
red=(RadioButton )findViewById(R.id.clrred);
blue = (RadioButton)findViewById(R.id.clrblue);
green = (RadioButton)findViewById(R.id.clrgreen);
orange = (RadioButton)findViewById(R.id.clrorange);
yellow = (RadioButton)findViewById(R.id.clryellow);
btnsubmit = (Button)findViewById(R.id.btnsubmit);
txtview = (TextView)findViewById(R.id.txtview) ;
lnrlayout = (LinearLayout) findViewById(R.id.lnrlayout);
btnsubmit.setOnClickListener(new View.OnClickListener() {
@Override
Android App with Radio button group – NITHIYAPRIYA PASAVARAJ
public void onClick(View view) {
if(red.isChecked())
{
txtview.setText("You've Selected Red");
lnrlayout.setBackgroundColor(Color.RED);
}
if(blue.isChecked())
{
txtview.setText("You've Selected Blue");
lnrlayout.setBackgroundColor(Color.BLUE);
}
if(green.isChecked())
{
txtview.setText("You've Selected Green");
lnrlayout.setBackgroundColor(Color.GREEN);
}
if(yellow.isChecked())
{
txtview.setText("You've Selected Yellow");
lnrlayout.setBackgroundColor(Color.YELLOW);
}
if(orange.isChecked())
{
txtview.setText("You've Selected Gray");
lnrlayout.setBackgroundColor(Color.DKGRAY);
//lnrlayout.setBackgroundColor(-565);
}
}
});
}
}

More Related Content

What's hot (20)

PPT
Debugging
Imran Memon
 
PDF
Basics of reflection in java
kim.mens
 
PPTX
.Net Assemblies
Muhammad Kamran Rafi
 
PDF
A Basic Django Introduction
Ganga Ram
 
PDF
Android Toast.pdf
John Benetic
 
PDF
Solid NodeJS with TypeScript, Jest & NestJS
Rafael Casuso Romate
 
PDF
Android for Embedded Linux Developers
Opersys inc.
 
PDF
Python Interview Questions And Answers
H2Kinfosys
 
PDF
Introduction to asp.net
SHADAB ALI
 
PPTX
Functional programming with Java 8
LivePerson
 
PPTX
ZIO: Powerful and Principled Functional Programming in Scala
Wiem Zine Elabidine
 
PDF
MongoDB- Crud Operation
Edureka!
 
PDF
Spring aop
Hamid Ghorbani
 
PPTX
Design Pattern - Singleton Pattern
Mudasir Qazi
 
PDF
Object-oriented Programming-with C#
Doncho Minkov
 
PDF
C# Lab Programs.pdf
Prof. Dr. K. Adisesha
 
PPSX
Exception hierarchy
Ashfaaq Mahroof
 
PPTX
Exceptions in Java
Vadym Lotar
 
PPTX
Java reflection
NexThoughts Technologies
 
PPTX
Exception handling
PhD Research Scholar
 
Debugging
Imran Memon
 
Basics of reflection in java
kim.mens
 
.Net Assemblies
Muhammad Kamran Rafi
 
A Basic Django Introduction
Ganga Ram
 
Android Toast.pdf
John Benetic
 
Solid NodeJS with TypeScript, Jest & NestJS
Rafael Casuso Romate
 
Android for Embedded Linux Developers
Opersys inc.
 
Python Interview Questions And Answers
H2Kinfosys
 
Introduction to asp.net
SHADAB ALI
 
Functional programming with Java 8
LivePerson
 
ZIO: Powerful and Principled Functional Programming in Scala
Wiem Zine Elabidine
 
MongoDB- Crud Operation
Edureka!
 
Spring aop
Hamid Ghorbani
 
Design Pattern - Singleton Pattern
Mudasir Qazi
 
Object-oriented Programming-with C#
Doncho Minkov
 
C# Lab Programs.pdf
Prof. Dr. K. Adisesha
 
Exception hierarchy
Ashfaaq Mahroof
 
Exceptions in Java
Vadym Lotar
 
Java reflection
NexThoughts Technologies
 
Exception handling
PhD Research Scholar
 

More from priya Nithya (19)

PPTX
Android Architecture.pptx
priya Nithya
 
PDF
Html server control - ASP. NET with c#
priya Nithya
 
PPTX
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
priya Nithya
 
PPTX
Asynchronous data transfer
priya Nithya
 
PDF
Asp.net state management
priya Nithya
 
DOC
HTTP REQUEST RESPONSE OBJECT - WEB APPLICATION USING C# LAB
priya Nithya
 
DOCX
HTML SERVER CONTROL - ASP.NET WITH C#
priya Nithya
 
PPTX
ASP.NET - Life cycle of asp
priya Nithya
 
DOC
Web application using c# Lab - Web Configuration file
priya Nithya
 
DOCX
Creation of simple application using - step by step
priya Nithya
 
PPSX
Adaptation of tcp window
priya Nithya
 
PPSX
Asp.net Overview
priya Nithya
 
PPSX
Key mechanism of mobile ip
priya Nithya
 
PPSX
Mobile ip overview
priya Nithya
 
PPSX
Features of mobile ip
priya Nithya
 
PDF
Creating a Name seperator Custom Control using C#
priya Nithya
 
PDF
How to Create Database component -Enterprise Application Using C# Lab
priya Nithya
 
PDF
Creating simple component
priya Nithya
 
PPT
Internet (i mcom)
priya Nithya
 
Android Architecture.pptx
priya Nithya
 
Html server control - ASP. NET with c#
priya Nithya
 
Modes of transfer - Computer Organization & Architecture - Nithiyapriya Pasav...
priya Nithya
 
Asynchronous data transfer
priya Nithya
 
Asp.net state management
priya Nithya
 
HTTP REQUEST RESPONSE OBJECT - WEB APPLICATION USING C# LAB
priya Nithya
 
HTML SERVER CONTROL - ASP.NET WITH C#
priya Nithya
 
ASP.NET - Life cycle of asp
priya Nithya
 
Web application using c# Lab - Web Configuration file
priya Nithya
 
Creation of simple application using - step by step
priya Nithya
 
Adaptation of tcp window
priya Nithya
 
Asp.net Overview
priya Nithya
 
Key mechanism of mobile ip
priya Nithya
 
Mobile ip overview
priya Nithya
 
Features of mobile ip
priya Nithya
 
Creating a Name seperator Custom Control using C#
priya Nithya
 
How to Create Database component -Enterprise Application Using C# Lab
priya Nithya
 
Creating simple component
priya Nithya
 
Internet (i mcom)
priya Nithya
 
Ad

Recently uploaded (20)

PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Dimensions of Societal Planning in Commonism
StefanMz
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
Ad

Android LAb - Creating an android app with Radio button

  • 1. Android App with Radio button group – NITHIYAPRIYA PASAVARAJ Android Application with Radio Button Activity_main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout 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" android:orientation="vertical" tools:context=".MainActivity" > <LinearLayout android:id="@+id/lnrlayout" android:layout_width="fill_parent" android:layout_height="756dp" android:orientation="vertical"> <TextView android:id="@+id/textView2"
  • 2. Android App with Radio button group – NITHIYAPRIYA PASAVARAJ android:layout_width="wrap_content" android:layout_height="72dp" android:text="Select Your Favorite Color" android:textColor="#7B1FA2" android:textSize="30sp" android:textStyle="bold" tools:layout_conversion_absoluteHeight="61dp" tools:layout_conversion_absoluteWidth="388dp" tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteY="0dp" /> <RadioGroup android:layout_width="355dp" android:layout_height="397dp"> <RadioButton android:id="@+id/clrred" android:layout_width="match_parent" android:layout_height="47dp" android:layout_weight="1" android:checked="false" android:text="Red" android:textAllCaps="true" android:textColor="#E64A19" android:textSize="24sp" android:textStyle="bold|italic" /> <RadioButton android:id="@+id/clrblue" android:layout_width="match_parent" android:layout_height="43dp" android:layout_weight="1" android:checked="false" android:text="Blue" android:textAllCaps="true" android:textColor="#512DA8" android:textSize="24sp" android:textStyle="bold|italic" /> <RadioButton android:id="@+id/clrgreen" android:layout_width="match_parent" android:layout_height="wrap_content"
  • 3. Android App with Radio button group – NITHIYAPRIYA PASAVARAJ android:layout_weight="1" android:text="Green" android:textAllCaps="true" android:textColor="#00796B" android:textSize="24sp" android:textStyle="bold|italic" /> <RadioButton android:id="@+id/clryellow" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Yellow" android:textAllCaps="true" android:textColor="#FBC02D" android:textSize="24sp" android:textStyle="bold|italic" /> <RadioButton android:id="@+id/clrorange" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:text="Gray" android:textAllCaps="true" android:textColor="#A3A39F" android:textSize="24sp" android:textStyle="bold|italic" /> </RadioGroup> <Button android:id="@+id/btnsubmit" android:layout_width="180dp" android:layout_height="60dp" android:layout_gravity="center" android:background="#9DC218" android:text="Submit" android:textAllCaps="true" android:textColor="#7B1FA2" android:textSize="30sp" android:textStyle="bold" />
  • 4. Android App with Radio button group – NITHIYAPRIYA PASAVARAJ <TextView android:id="@+id/txtview" android:layout_width="match_parent" android:layout_height="132dp" android:textSize="30sp" android:textStyle="bold" /> </LinearLayout> </LinearLayout> Mainactivity.java package com.example.radiobtngrp; import androidx.appcompat.app.AppCompatActivity; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.RadioButton; import android.widget.TextView; public class MainActivity extends AppCompatActivity { RadioButton red,blue,green,yellow,orange; Button btnsubmit; TextView txtview; LinearLayout lnrlayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); red=(RadioButton )findViewById(R.id.clrred); blue = (RadioButton)findViewById(R.id.clrblue); green = (RadioButton)findViewById(R.id.clrgreen); orange = (RadioButton)findViewById(R.id.clrorange); yellow = (RadioButton)findViewById(R.id.clryellow); btnsubmit = (Button)findViewById(R.id.btnsubmit); txtview = (TextView)findViewById(R.id.txtview) ; lnrlayout = (LinearLayout) findViewById(R.id.lnrlayout); btnsubmit.setOnClickListener(new View.OnClickListener() { @Override
  • 5. Android App with Radio button group – NITHIYAPRIYA PASAVARAJ public void onClick(View view) { if(red.isChecked()) { txtview.setText("You've Selected Red"); lnrlayout.setBackgroundColor(Color.RED); } if(blue.isChecked()) { txtview.setText("You've Selected Blue"); lnrlayout.setBackgroundColor(Color.BLUE); } if(green.isChecked()) { txtview.setText("You've Selected Green"); lnrlayout.setBackgroundColor(Color.GREEN); } if(yellow.isChecked()) { txtview.setText("You've Selected Yellow"); lnrlayout.setBackgroundColor(Color.YELLOW); } if(orange.isChecked()) { txtview.setText("You've Selected Gray"); lnrlayout.setBackgroundColor(Color.DKGRAY); //lnrlayout.setBackgroundColor(-565); } } }); } }