0% found this document useful (0 votes)
18 views4 pages

Practical 11

The document contains exercises for a Mobile Application Development course, including a program that demonstrates the use of radio buttons with and without a radio group, along with associated XML and Java code. It also includes a second exercise requiring a program to center Name, Age, and Mobile Number on the display screen using Absolute layout. The document features code snippets and expected outputs for both exercises.

Uploaded by

sainathkorpakwad
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)
18 views4 pages

Practical 11

The document contains exercises for a Mobile Application Development course, including a program that demonstrates the use of radio buttons with and without a radio group, along with associated XML and Java code. It also includes a second exercise requiring a program to center Name, Age, and Mobile Number on the display screen using Absolute layout. The document features code snippets and expected outputs for both exercises.

Uploaded by

sainathkorpakwad
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
You are on page 1/ 4

Subject :- Mobile Application Developmen Subject Code :- 22617

Name :- Shivam Sainath Korpakwad Batch :- CO 6 IA Roll No. 24

Exercise :-

1). Write a program show the following output First two radio buttons are without using
radio groop and next two radio buttons are using radio group. Note the changes
between these two. Also toast which radio button has been selected.

Code :-
XML:Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".MainActivity ">
<TextView android:id="@+id/textv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Single Radio Buttons"
android:textColor="#000000 "
android:visibility="visible"
android:layout_centerHorizo ntal="true"
android:textSize="20dp"
android:layout_marginTop=" 20dp"
/>
<RadioButton
android:id="@+id/radioButt on1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Radio Button 1"
android:layout_marginTop=" 80dp"
android:textSize="40dp"
/>
<RadioButton
android:id="@+id/radioButt on2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Radio Button 2"
android:layout_marginTop=" 40dp"
android:layout_below="@+id/radioButton1"
android:textSize="40dp"
/>
<RadioGroup android:layout_below="@+id/radioButton2"
android:layout_width="matc h_parent"
android:layout_height="200d p"
android:layout_marginTop="50dp"
android:id="@+id/radioGrou p">
<TextView android:id="@+id/textvr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Radio button inside RadioGroup"
android:textSize="20dp"
android:textColor="#000000 "
android:visibility="visible"
android:layout_marginTop=" 25dp"
/>
<RadioButton
android:id="@+id/male" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:checked="true" android:textSize="40dp"
/>
<RadioButton
android:id="@+id/female" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Female"
android:checked="true"
android:textSize="40dp"
/>
</RadioGroup>
<Button android:id="@+id/Select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select"
android:layout_centerHorizo ntal="true"
android:layout_below="@+id/radioGroup"
/>
</RelativeLayout> Java Code:
package com.example.exp12;
import androidx.appcompat.app.App CompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity
{
RadioButton radgender,rad1,rad2;
RadioGroup radSelect;
String gender;
Button select;
@Override protected voidonCreate(BundlesavedInstanceState)
{
super.onCreate(savedInstance State);
setContentView(R.layout.acti vity_main);
radSelect=findViewById(R.id.radioGroup);
rad1=findViewById(R.id.radi oButton1);
rad2=findViewById(R.id.radi oButton2);
{
int radioID= radSelect.getCheckedRadioB uttonId();
radgender=findViewById(rad ioID);
gender=radgender.getText().t oString().trim();
if(rad1.isChecked())
{
Toast.makeText(this, "Radio button 1 is selected", Toast.LENGTH_SHORT).show();
select=findViewById(R.id.Sel ect);}
if(rad2.isChecked())
{
select.setOnClickListener( new View.OnClickListener()
{
Public void onClick(View v)
{
select();
}
}
);
}
public void select()
Toast.makeText(this, "Radio button 2 is selected", Toast.LENGTH_SHORT).show();
}
Toast.makeText(this, "Gender :" + gender, Toast.LENGTH_SHORT).show();
}
}

Output :-
Subject :- Mobile Application Developmen Subject Code :- 22617
Name :- Shivam Sainath Korpakwad Batch :- CO 6 IA Roll No. 24

Exercise :-

2). Write a program to place Name, Age and Mobile Number centrally on the display
screen using Absolute layout.

Code :-

Output :-

You might also like