0% found this document useful (0 votes)
8 views9 pages

Android Programs8 10

The document contains three Android application programs: one for checking items using checkboxes, another for selecting items using radio buttons, and a third for adding two numbers. Each program includes XML layout files and corresponding Java code for functionality, with successful execution results noted. The applications demonstrate basic user interface elements and event handling in Android development.

Uploaded by

midhunnandanan07
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

Android Programs8 10

The document contains three Android application programs: one for checking items using checkboxes, another for selecting items using radio buttons, and a third for adding two numbers. Each program includes XML layout files and corresponding Java code for functionality, with successful execution results noted. The applications demonstrate basic user interface elements and event handling in Android development.

Uploaded by

midhunnandanan07
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CHECKBOX

No.8
Date:15/15/2025
Aim:
Write a program to check the items listed
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<[Link] ">

<CheckBox
android:id="@+id/chbandroid"
android:layout_width="278dp"
android:layout_height="66dp"

android:text="Android"/>

<CheckBox
android:id="@+id/chbjava"
android:layout_width="277dp"
android:layout_height="56dp"

android:text="Java"/>

<Button
android:id="@+id/btnSelect"
android:layout_width="255dp"
android:layout_height="96dp"
android:text="SELECT"
/>
</[Link]>
[Link]

package [Link];

import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {


CheckBox chb1,chb2;
Button bt;
StringBuffer result;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
chb1=findViewById([Link]);
chb2=findViewById([Link]);

bt=findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View view) {
result=new StringBuffer();

if([Link]())
{
[Link]([Link]()+" ");
}
if([Link]())
{
[Link]([Link]()+" ");
}
[Link](getApplicationContext(),"Checked
Languages:"+[Link](),Toast.LENGTH_LONG).show();
}

}
});
}
}

Result:
The program executed successfully and obtained the result.
RADIO BUTTON

No:9
03/02/2025
Aim:
Write a program to select item using radio button.
Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<[Link] >

<RadioGroup
android:id="@+id/radiogrp"
android:layout_width="174dp"
android:layout_height="0dp"
>

<RadioButton
android:id="@+id/radio1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Female" />

<RadioButton
android:id="@+id/radio2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Male" />
<RadioButton
android:id="@+id/radio3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Other" />

</RadioGroup>
<TextView
android:id="@+id/txtpg"
android:layout_width="171dp"
android:layout_height="47dp"
/>
</[Link]>

Main [Link]

package [Link];

import [Link];

import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {


RadioGroup rbg;
RadioButton rbpg;

TextView txtresult;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

rbg=findViewById([Link]);
txtresult=findViewById([Link]);
[Link](new
[Link]() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
rbpg=findViewById(i);
[Link]("Gender:"+[Link]().toString());
}
});
}
}

Result:
The program executed successfully and obtained the result.
ADDITION OF TWO NUMBERS
No:10
16/12/2025
Aim
Write a program to add two numbers.
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<[Link] >

<EditText
android:id="@+id/txtresult"
android:layout_width="wrap_content"
android:layout_heightht="wrap_content"
/>

<EditText
android:id="@+id/txtnum1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

<EditText
android:id="@+id/txtnum2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>

<Button
android:id="@+id/btnadd"
android:layout_width="204dp"
android:layout_height="58dp"
android:text="ADD"
/>
</[Link]>
[Link]

package [Link];

import [Link];

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {

EditText txt1,txt2,txt3;
Button btn;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

txt1=findViewById([Link].txtnum1);
txt2=findViewById([Link].txtnum2);
txt3=findViewById([Link]);

btn=findViewById([Link]);

[Link](new [Link]() {
@Override
public void onClick(View view) {

Integer num1=[Link]([Link]().toString());
Integer num2=[Link]([Link]().toString());

[Link](""+(num1+num2));
}
});
}

Result:
The program executed successfully and obtained the result.

You might also like