0% found this document useful (0 votes)
83 views49 pages

Android App Development Problemsheet

Uploaded by

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

Android App Development Problemsheet

Uploaded by

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

Android PROBLEMSHEET - 1 SYSTEM

1. Create “Hello World” application. That will display “Hello World” in the middle
of the screen in the red color with white background.
➢ activity_main.xml

<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textColor=" #FF0000"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</[Link]>

 Output :

2. Create an application Using Button, TextView, EditText Display Your Full Name
In TextView with the help of Button Click Event.
➢ activity_main.xml

<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]

1
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:id="@+id/display"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:hint="Your Name Display Here"
android:textSize="25dp"
android:textAlignment="center"/>

<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="140dp"
android:text="Click Here"/>

<EditText
android:id="@+id/Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="128dp"
android:ems="10"
android:hint="Enter Your Name Here"
android:textSize="22dp"
android:textAlignment="center"
android:inputType="text"/>

</[Link]>

➢ [Link]

public class MainActivity extends AppCompatActivity {


EditText Name;
Button btn;
TextView display;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
Name=(EditText) findViewById([Link]);
btn=(Button) findViewById([Link]);
display=(TextView) findViewById([Link]);

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]([Link]().toString());
}
});
}
}

 Output :

2
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

3. Create an application For cafeteria which contain.


• Item Name(Coffee,Pizza,Burger,Pasta,Brownee)
• Item Price Using Checkbox control generate bill of selected Items.

➢ Activity_main.xml
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:layout_editor_absoluteX="1dp"
tools:layout_editor_absoluteY="1dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" C"
android:textAlignment="center"
android:textColor="#1A3CE8"
android:textSize="30dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="afe"
android:textAlignment="center"
android:textColor="#E81A53"

3
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:textSize="25dp" />
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="10dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select From Here"
android:layout_marginLeft="10dp"
android:textColor="#1A3CE8"/>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<CheckBox
android:id="@+id/cb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Coffee"
tools:layout_editor_absoluteX="50dp"
tools:layout_editor_absoluteY="148dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="99/-" />

<EditText
android:id="@+id/cb1Q"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:inputType="number"
android:hint="Enter Quantity"/>
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/cb2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pizza"
tools:layout_editor_absoluteX="50dp"
tools:layout_editor_absoluteY="148dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="58dp"

4
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:text="499/-" />

<EditText
android:id="@+id/cb2Q"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="43dp"
android:inputType="number"
android:hint="Enter Quantity"/>
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/cb3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Burger"
tools:layout_editor_absoluteX="50dp"
tools:layout_editor_absoluteY="148dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="49dp"
android:text="129/-" />

<EditText
android:id="@+id/cb3Q"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="42dp"
android:inputType="number"
android:hint="Enter Quantity"/>
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/cb4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pasta"
tools:layout_editor_absoluteX="50dp"
tools:layout_editor_absoluteY="148dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="55dp"
android:text="149/-" />

<EditText
android:id="@+id/cb4Q"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="41dp"
android:inputType="number"
android:hint="Enter Quantity"/>

5
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/cb5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Brownie"
tools:layout_editor_absoluteX="50dp"
tools:layout_editor_absoluteY="148dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:text="299/-" />

<EditText
android:id="@+id/cb5Q"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:inputType="number"
android:hint="Enter Quantity"/>
</LinearLayout>
</LinearLayout>

<Button
android:id="@+id/bill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Make Bill"
android:layout_marginLeft="150dp"/>

<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<TableRow
android:id="@+id/time"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TableRow
android:id="@+id/heading"
android:background="#101112">

<TextView
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Sr No."
android:textAlignment="center"
android:textColor="@color/white"/>

<TextView

6
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_width="92dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Product Name"
android:textAlignment="center"
android:textColor="@color/white"/>

<TextView
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Price Per/Peice"
android:textAlignment="center"
android:textColor="@color/white"/>

<TextView
android:layout_width="56dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Quantity"
android:textAlignment="center"
android:textColor="@color/white"/>

<TextView
android:layout_width="69dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Total Price"
android:textAlignment="center"
android:textColor="@color/white"/>
</TableRow>

<TableRow
android:id="@+id/Ro1">

<TextView
android:id="@+id/p1sr"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p1name"
android:layout_width="92dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Coffee"
android:textAlignment="center"/>

<TextView
android:id="@+id/p1per"

7
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="99"
android:textAlignment="center" />

<TextView
android:id="@+id/p1Q"
android:layout_width="56dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p1pri"
android:layout_width="69dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>
</TableRow>

<TableRow
android:id="@+id/Ro2">

<TextView
android:id="@+id/p2sr"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p2name"
android:layout_width="92dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Pizza"
android:textAlignment="center"/>

<TextView
android:id="@+id/p2per"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="499"
android:textAlignment="center" />

<TextView
android:id="@+id/p2Q"
android:layout_width="56dp"

8
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p2pri"
android:layout_width="69dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>
</TableRow>

<TableRow
android:id="@+id/Ro3">

<TextView
android:id="@+id/p3sr"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p3name"
android:layout_width="92dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Burger"
android:textAlignment="center"/>

<TextView
android:id="@+id/p3per"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="149"
android:textAlignment="center" />

<TextView
android:id="@+id/p3Q"
android:layout_width="56dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p3pri"
android:layout_width="69dp"
android:layout_height="wrap_content"

9
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>
</TableRow>

<TableRow
android:id="@+id/Ro4">

<TextView
android:id="@+id/p4sr"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p4name"
android:layout_width="92dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Pasta"
android:textAlignment="center"/>

<TextView
android:id="@+id/p4per"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="129"
android:textAlignment="center" />

<TextView
android:id="@+id/p4Q"
android:layout_width="56dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p4pri"
android:layout_width="69dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>
</TableRow>

<TableRow
android:id="@+id/Ro5">

<TextView

10
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:id="@+id/p5sr"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p5name"
android:layout_width="92dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="Brownie"
android:textAlignment="center"/>

<TextView
android:id="@+id/p5per"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text="299"
android:textAlignment="center" />

<TextView
android:id="@+id/p5Q"
android:layout_width="56dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/p5pri"
android:layout_width="69dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>
</TableRow>

<TableRow>

<TextView
android:id="@+id/srspe"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/namespe"
android:layout_width="92dp"

11
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/textspe"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_span="2"
android:layout_marginLeft="10dp"
android:text="Special Discount (10%)"
android:textAlignment="center" />

<TextView
android:id="@+id/dispri"
android:layout_width="69dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>
</TableRow>

<TableRow>

<TextView
android:id="@+id/srtotal"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/nametotal"
android:layout_width="92dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>

<TextView
android:id="@+id/texttotal"
android:layout_width="99dp"
android:layout_height="wrap_content"
android:layout_span="2"
android:layout_marginLeft="10dp"
android:text="Total Amount"
android:textAlignment="center" />

<TextView
android:id="@+id/total"
android:layout_width="69dp"
android:layout_height="wrap_content"
android:layout_column="1"

12
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_marginLeft="10dp"
android:text=""
android:textAlignment="center"/>
</TableRow>

</TableLayout>
</LinearLayout>

</[Link]>

➢ [Link]
public class MainActivity extends AppCompatActivity {
CheckBox cb1,cb2,cb3,cb4,cb5;
EditText cb1Q,cb2Q,cb3Q,cb4Q,cb5Q;
TextView p1sr,p2sr,p3sr,p4sr,p5sr;
TextView p1Q,p2Q,p3Q,p4Q,p5Q;
TextView p1pri,p2pri,p3pri,p4pri,p5pri;
TextView dispri,total;
LinearLayout billkd;
TableRow time,heading,Ro1,Ro2,Ro3,Ro4,Ro5;

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

// Menu
cb1=(CheckBox) findViewById([Link].cb1);
cb2=(CheckBox) findViewById([Link].cb2);
cb3=(CheckBox) findViewById([Link].cb3);
cb4=(CheckBox) findViewById([Link].cb4);
cb5=(CheckBox) findViewById([Link].cb5);

p1sr=(TextView) findViewById([Link].p1sr);
p2sr=(TextView) findViewById([Link].p2sr);
p3sr=(TextView) findViewById([Link].p3sr);
p4sr=(TextView) findViewById([Link].p4sr);
p5sr=(TextView) findViewById([Link].p5sr);

p1Q=(TextView) findViewById([Link].p1Q);
p2Q=(TextView) findViewById([Link].p2Q);
p3Q=(TextView) findViewById([Link].p3Q);
p4Q=(TextView) findViewById([Link].p4Q);
p5Q=(TextView) findViewById([Link].p5Q);

p1pri=(TextView) findViewById([Link].p1pri);
p2pri=(TextView) findViewById([Link].p2pri);
p3pri=(TextView) findViewById([Link].p3pri);
p4pri=(TextView) findViewById([Link].p4pri);
p5pri=(TextView) findViewById([Link].p5pri);

total=(TextView) findViewById([Link]);

billkd=(LinearLayout) findViewById([Link]);

13
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

time=(TableRow) findViewById([Link]);
heading=(TableRow) findViewById([Link]);

Ro1=(TableRow) findViewById([Link].Ro1);
Ro2=(TableRow) findViewById([Link].Ro2);
Ro3=(TableRow) findViewById([Link].Ro3);
Ro4=(TableRow) findViewById([Link].Ro4);
Ro5=(TableRow) findViewById([Link].Ro5);

billbtn=(Button) findViewById([Link]);

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]("1");
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]("1");
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]("1");
}
});
[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]("1");
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]("1");
}
});

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

sr=0;
[Link]("0");
[Link]("0");
[Link]("0");
[Link]("0");
[Link]("0");

if([Link]()){
sr=sr+1;

14
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

[Link]([Link](sr));
int a,b;
String str;
str=[Link]().toString();
a=[Link](str);
b=a*99;
[Link]([Link](a));
[Link]([Link](b));
}
if([Link]()){
sr=sr+1;
[Link]([Link](sr));
int a,b;
a=[Link]([Link]().toString());
b=a*499;
[Link]([Link](a));
[Link]([Link](b));
}
if([Link]()){
sr=sr+1;
[Link]([Link](sr));
int a,b;
a=[Link]([Link]().toString());
b=a*129;
[Link]([Link](a));
[Link]([Link](b));
}
if([Link]()){
sr=sr+1;
[Link]([Link](sr));
int a,b;
a=[Link]([Link]().toString());
b=a*149;
[Link]([Link](a));
[Link]([Link](b));
}
if([Link]()){
sr=sr+1;
[Link]([Link](sr));
int a,b;
a=[Link]([Link]().toString());
b=a*299;
[Link]([Link](a));
[Link]([Link](b));
}
int a,b,c,d,e,ans,dis;
a=[Link]([Link]().toString());
b=[Link]([Link]().toString());
d=[Link]([Link]().toString());
e=[Link]([Link]().toString());
ans=a+b+c+d+e;
dis=ans*10/100;
[Link]([Link](dis));
[Link]([Link](ans-dis));

}
});
}
}

15
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

 Output :

4. Create an application For BSC CS Subject Name Programing in C++ •


Advance Java • Data Structure • Software Engineering Using RadioGroup and
RadioButton Control. Put TextView in below of each subject Radio button and
explain about selected subject in Briefly. (Note: Set visibility of textview
according to selected radio button.)
➢ Activity_main.xml
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<RadioButton
android:id="@+id/cppr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Programing in C++" />

<RadioButton
android:id="@+id/javar"
android:layout_width="wrap_content"

16
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_height="wrap_content"
android:text="Advance Java" />

<RadioButton
android:id="@+id/dsr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Data Structure" />

<RadioButton
android:id="@+id/ser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Software Engineering" />

</RadioGroup>

<ImageView
android:id="@+id/cpp"
android:layout_width="277dp"
android:layout_height="441dp"
android:src="@drawable/cpp2"/>
<ImageView
android:id="@+id/ds"
android:layout_width="277dp"
android:layout_height="441dp"
android:src="@drawable/ds2"/>
<ImageView
android:id="@+id/se"
android:layout_width="277dp"
android:layout_height="441dp"
android:src="@drawable/se2"
app:layout_constraintTop_toBottomOf="@+id/radioGroup" />
<ImageView
android:id="@+id/java"
android:layout_width="277dp"
android:layout_height="441dp"
android:src="@drawable/java"/>

</[Link]>

➢ [Link]

public class MainActivity extends AppCompatActivity {


RadioButton cppr,dsr,ser,javar;
ImageView cpp,ds,se,java;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
cppr=(RadioButton) findViewById([Link]);
dsr=(RadioButton) findViewById([Link]);
ser=(RadioButton) findViewById([Link]);
javar=(RadioButton) findViewById([Link]);

[Link](new [Link]() {
@Override

17
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

public void onClick(View view) {


[Link]([Link]);
}
});

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

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

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

 Output :

5. Understand Menu option. Create an application that will change color of the
screen, based on selected options from the menu.
➢ Activity_main.xml
<[Link]
xmlns:android="[Link]
android:id="@+id/cl"

18
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<Spinner
android:id="@+id/colors"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:entries="@array/colors"
app:layout_constraintCircleRadius="20dp"
android:spinnerMode="dropdown/>

</[Link]>

➢ [Link]

public class MainActivity extends AppCompatActivity {

Spinner colors;
ConstraintLayout cl;

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

colors = findViewById([Link]);
cl = findViewById([Link]);
ArrayAdapter<CharSequence> adapter = [Link](this,
[Link], [Link].simple_spinner_item);

[Link]([Link].simple_spinner_dropdown_item);

[Link](adapter);

[Link](new [Link]() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView,
int position, long id) {
String selectedColor = [Link]().toString();
int backgroundColor,backgroundColorsp;

switch (selectedColor) {
case "White":
backgroundColor = [Link]("#FFFFFF");
backgroundColorsp = [Link]("#363638");
break;
case "Pink":
backgroundColor = [Link]("#C42771");
backgroundColorsp = [Link]("#FFFFFF");
break;
case "Red":
backgroundColor = [Link]("#FA0707");
backgroundColorsp = [Link]("#FFFFFF");
break;
case "Yellow":

19
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

backgroundColor = [Link]("#FFFF00");
backgroundColorsp = [Link]("#FFFFFF");
break;
case "Gray":
backgroundColor = [Link]("#363638");
backgroundColorsp = [Link]("#FFFFFF");
break;
default:
// Default background color when none of the cases match
backgroundColor = [Link];
backgroundColorsp = [Link];
break;
}

[Link](backgroundColor);
[Link](backgroundColorsp);
}

@Override
public void onNothingSelected(AdapterView<?> parentView) {
}
});
}
}

 Output :

6. Android Program to Perform all Operations using Calculators


➢ Activity_main.xml
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

20
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

<TextView
android:id="@+id/ans"
android:layout_width="349dp"
android:layout_height="46dp"
android:layout_marginTop="20dp"
android:editable="true"
android:fontFamily="verdana"
android:hint="0"
android:inputType="number"
android:text="0"
android:textAlignment="viewEnd"
android:textSize="34sp"
tools:layout_editor_absoluteX="31dp" />

<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="409dp"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@+id/ans"
tools:layout_editor_absoluteX="1dp">

<Button
android:id="@+id/clr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AC" />

<Button
android:id="@+id/mod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="%" />

<Button
android:id="@+id/div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/" />

<Button
android:id="@+id/mul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*" />
</LinearLayout>

<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="409dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@+id/linearLayout"
tools:layout_editor_absoluteX="1dp">

<Button
android:id="@+id/no7"

21
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="7" />

<Button
android:id="@+id/no8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="8" />

<Button
android:id="@+id/no9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9" />

<Button
android:id="@+id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="-" />
</LinearLayout>

<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="409dp"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout3"
app:layout_constraintVertical_bias="0.0"
tools:layout_editor_absoluteX="1dp">

<Button
android:id="@+id/no4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="4" />
<Button
android:id="@+id/no5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="5" />

<Button
android:id="@+id/no6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="6" />

<Button

22
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:id="@+id/add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="+" />

</LinearLayout>

<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width="314dp"
android:layout_height="46dp"
android:layout_marginTop="32dp"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@+id/linearLayout4"
tools:layout_editor_absoluteX="1dp">

<Button
android:id="@+id/no1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1" />

<Button
android:id="@+id/no2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2" />

<Button
android:id="@+id/no3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3" />

</LinearLayout>

<LinearLayout
android:layout_width="308dp"
android:layout_height="52dp"
android:layout_marginTop="32dp"
android:orientation="horizontal"
app:layout_constraintEnd_toStartOf="@+id/eql"
app:layout_constraintTop_toBottomOf="@+id/linearLayout5">

<Button
android:id="@+id/no0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="0" />

<Button
android:id="@+id/no00"
android:layout_width="wrap_content"

23
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_height="wrap_content"
android:layout_weight="1"
android:text="00" />

<Button
android:id="@+id/dot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="." />
</LinearLayout>

<Button
android:id="@+id/eql"
android:layout_width="95dp"
android:layout_height="129dp"
android:layout_marginTop="32dp"
android:layout_weight="1"
android:text="="
app:layout_constraintStart_toEndOf="@+id/linearLayout5"
app:layout_constraintTop_toBottomOf="@+id/linearLayout4" />

<TextView
android:id="@+id/tmp"
android:layout_width="349dp"
android:layout_height="40dp"
android:layout_marginTop="24dp"
android:fontFamily="verdana"
android:hint="0"
android:inputType="number"
android:numeric="signed|integer|decimal"
android:text="0"/>

</[Link]>

 [Link]

public class MainActivity extends AppCompatActivity {


TextView ans,tmp;
Button clr;
Button n1,n2,n3,n4,n5,n6,n7,n8,n9,n0,n00;
Button add,sub,mul,div,mod;
Button dot;
Button eql;

String opera="";

Float a,b,c;
int zero;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
ans = (TextView)findViewById([Link]);
tmp = (TextView)findViewById([Link]);
n1 = (Button)findViewById([Link].no1);
n2 = (Button)findViewById([Link].no2);
n3 = (Button)findViewById([Link].no3);

24
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

n4 = (Button)findViewById([Link].no4);
n5 = (Button)findViewById([Link].no5);
n6 = (Button)findViewById([Link].no6);
n7 = (Button)findViewById([Link].no7);
n8 = (Button)findViewById([Link].no8);
n9 = (Button)findViewById([Link].no9);
n0 = (Button)findViewById([Link].no0);

add = (Button)findViewById([Link]);
sub = (Button)findViewById([Link]);
mul = (Button)findViewById([Link]);
div = (Button)findViewById([Link]);
mod = (Button)findViewById([Link]);

dot = (Button)findViewById([Link]);
eql = (Button)findViewById([Link]);
clr = (Button)findViewById([Link]);

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
zero = [Link]([Link]().toString());
[Link]([Link]().toString()+[Link]().toString());
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
zero = [Link]([Link]().toString());
[Link]([Link]().toString()+[Link]().toString());
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
zero = [Link]([Link]().toString());
[Link]([Link]().toString()+[Link]().toString());
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
zero = [Link]([Link]().toString());
[Link]([Link]().toString()+[Link]().toString());
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
zero = [Link]([Link]().toString());
[Link]([Link]().toString()+[Link]().toString());
}
});

[Link](new OnClickListener() {

25
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

@Override
public void onClick(View view) {
zero = [Link]([Link]().toString());
[Link]([Link]().toString()+[Link]().toString());
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
zero = [Link]([Link]().toString());
if(zero == 0){
[Link]("");
}
[Link]([Link]().toString()+[Link]().toString());
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
zero = [Link]([Link]().toString());
[Link]([Link]().toString()+[Link]().toString());
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
zero = [Link]([Link]().toString());
if(zero == 0){
[Link]("");
}
[Link]([Link]().toString()+[Link]().toString());
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
a = [Link]([Link]().toString());
b = [Link]([Link]().toString());
if (a == 0){
[Link]([Link](b));
} else if (a == 0.0) {
[Link]([Link](b));
}
[Link]([Link](c));
[Link]("0");
opera = "+";
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
a = [Link]([Link]().toString());
b = [Link]([Link]().toString());
if (a == 0){

26
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

[Link]([Link](b));
} else if (a == 0.0) {
[Link]([Link](b));
}
[Link]([Link](c));
[Link]("0");
opera = "-";
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
a = [Link]([Link]().toString());
b = [Link]([Link]().toString());
if (a == 0){
[Link]([Link](b));
}
[Link]([Link](c));
[Link]("0");
opera = "*";
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
a = [Link]([Link]().toString());
b = [Link]([Link]().toString());
if (a == 0){
[Link]([Link](b));
}
[Link]([Link](c));
[Link]("0");
opera = "/";
}
});

[Link](new OnClickListener() {
@Override
public void onClick(View view) {
a = [Link]([Link]().toString());
b = [Link]([Link]().toString());
if (a == 0){
[Link]([Link](b));
} else if (a == 0.0) {
[Link]([Link](b));
}
[Link]([Link](c));
[Link]("0");
opera = "%";
}
});
[Link](new OnClickListener() {
@Override
public void onClick(View view) {
a = [Link]([Link]().toString());
b = [Link]([Link]().toString());
if (opera == "+") {

27
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

c = a + b;
} else if (opera == "-") {
c = a - b;
} else if (opera == "*") {
c = a * b;
} else if (opera == "/") {
c = a / b;
} else {
c = a % b;
}
[Link]([Link](c));
[Link]("0.0");
}
});

}
}

 Output :

7. To understand Activity, Intent • Create sample application with login


module.(Check username and password) • On successful login, go to next
screen And Display Username/Password and on failing login, alert user using
Toast.
➢ Activity_main.xml
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:id="@+id/uname"

28
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="132dp"
android:ems="10"
android:hint="Name"
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/uname" />

<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="88dp"
android:text="Login"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pass" />

</[Link]>

➢ [Link]

public class MainActivity extends AppCompatActivity {

EditText name,pass;
Button login;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

name=(EditText) findViewById([Link]);
pass=(EditText) findViewById([Link]);
login=(Button) findViewById([Link]);

[Link](new [Link]() {
@Override
public void onClick(View view) {
Intent i = new Intent([Link],[Link]);
[Link]("Name",[Link]().toString());
[Link]("Pass",[Link]().toString());
startActivity(i);
}
});

29
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

}
}

➢ Activity_getpage.xml

<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".getpage">

<TextView
android:id="@+id/unm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="148dp"
android:text="TextView"
android:textColor="#13134d"
android:textSize="30dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/passw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="88dp"
android:text="TextView"
android:textSize="25dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.482"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/unm" />

<Button
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="252dp"
android:text="Back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/passw"
app:layout_constraintVertical_bias="0.0" />

</[Link]>

➢ [Link]

public class getpage extends AppCompatActivity {

30
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

TextView unm,passw;
Button back;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_getpage);
unm=(TextView) findViewById([Link]);
passw=(TextView) findViewById([Link]);
back=(Button) findViewById([Link]);

Intent i = getIntent();
String str1 = [Link]("Name1");
String str2 = [Link]("Pass1");
[Link]("WellCome "+str1+"!");
[Link]("Your Password is "+"\""+str2+"\"");

[Link](new [Link]() {
@Override
public void onClick(View view) {
Intent i = new Intent([Link],[Link]);
startActivity(i);
}
});
}
}

 Output :

8. Create and Login application as above . On successful login , open browser


with any URL
➢ Activity_main.xml
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]

31
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:id="@+id/uname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="132dp"
android:ems="10"
android:hint="Name"
android:inputType="text"/>

<EditText
android:id="@+id/pass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="44dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"/>

<Button
android:id="@+id/login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="88dp"
android:text="Login"/>
</[Link]>

➢ [Link]

public class MainActivity extends AppCompatActivity {

EditText name,pass;
Button login;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

name=(EditText) findViewById([Link]);
pass=(EditText) findViewById([Link]);
login=(Button) findViewById([Link]);

[Link](new [Link]() {
@Override
public void onClick(View view) {
Uri webpage = [Link]("[Link]
Intent i = new Intent(Intent.ACTION_VIEW, webpage);
startActivity(i);

}
});
}
}

 Output :

32
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

9. Create an application that designs a layout which provides field for enrollment
number (text box), student’s name (text box), course (radio buttons),
semester (radio buttons)) and marks for sub1 (text box), sub2 (text box),
sub3 (text box) and a button name submit. Total and percentage should be
calculated automatically
➢ Activity_main.xml
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:id="@+id/enrno"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="4dp"
android:ems="10"
android:hint="Enrollment No. "
android:text=""
android:inputType="number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.034"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:ems="10"

33
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:hint="Your Name "


android:text=""
android:inputType="text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.034"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/enrno" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Select Course"/>

<RadioGroup
android:id="@+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:orientation="horizontal"
android:transitionName="hii"">

<RadioButton
android:id="@+id/bca"
android:layout_width="83dp"
android:layout_height="wrap_content"
android:text="BCA"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />

<RadioButton
android:id="@+id/mca"
android:layout_width="83dp"
android:layout_height="wrap_content"
android:text="MCA"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />

<RadioButton
android:id="@+id/bscit"
android:layout_width="83dp"
android:layout_height="wrap_content"
android:text="BSCIT"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />

<RadioButton
android:id="@+id/mscit"
android:layout_width="83dp"
android:layout_height="wrap_content"
android:text="MSCIT"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />

<RadioButton
android:id="@+id/bed"
android:layout_width="83dp"
android:layout_height="wrap_content"

34
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:text="BED"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />

</RadioGroup>

<RadioGroup
android:id="@+id/radioGroup2"
android:layout_width="wrap_content"
android:layout_height="46dp"
android:orientation="horizontal"
android:transitionName="hii"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.092"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/radioGroup">

<RadioButton
android:id="@+id/bba"
android:layout_width="83dp"
android:layout_height="wrap_content"
android:text="BBA"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />

<RadioButton
android:id="@+id/mba"
android:layout_width="83dp"
android:layout_height="wrap_content"
android:text="MBA"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />

<RadioButton
android:id="@+id/bcom"
android:layout_width="83dp"
android:layout_height="wrap_content"
android:text="BCOM"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />

<RadioButton
android:id="@+id/mcom"
android:layout_width="83dp"
android:layout_height="wrap_content"
android:text="MCOM"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />

<RadioButton
android:id="@+id/med"
android:layout_width="83dp"
android:layout_height="wrap_content"
android:text="MED"
tools:layout_editor_absoluteX="86dp"
tools:layout_editor_absoluteY="391dp" />
</RadioGroup>

<TextView

35
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Select Semester"/>

<RadioGroup
android:id="@+id/radioGroup3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:orientation="horizontal"

<RadioButton
android:id="@+id/sem1"
android:layout_width="68dp"
android:layout_height="wrap_content"
android:text="1"
tools:layout_editor_absoluteX="109dp"
tools:layout_editor_absoluteY="406dp" />

<RadioButton
android:id="@+id/sem2"
android:layout_width="68dp"
android:layout_height="wrap_content"
android:text="2"
tools:layout_editor_absoluteX="109dp"
tools:layout_editor_absoluteY="406dp" />

<RadioButton
android:id="@+id/sem3"
android:layout_width="68dp"
android:layout_height="wrap_content"
android:text="3"
tools:layout_editor_absoluteX="109dp"
tools:layout_editor_absoluteY="406dp" />

<RadioButton
android:id="@+id/sem4"
android:layout_width="68dp"
android:layout_height="wrap_content"
android:text="4"
tools:layout_editor_absoluteX="109dp"
tools:layout_editor_absoluteY="406dp" />

<RadioButton
android:id="@+id/sem5"
android:layout_width="68dp"
android:layout_height="wrap_content"
android:text="5"
tools:layout_editor_absoluteX="109dp"
tools:layout_editor_absoluteY="406dp" />

<RadioButton
android:id="@+id/sem6"
android:layout_width="68dp"
android:layout_height="wrap_content"
android:text="6"
tools:layout_editor_absoluteX="109dp"

36
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

tools:layout_editor_absoluteY="406dp" />

</RadioGroup>

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="Enter 3 Subjects Marks "/>

<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:orientation="horizontal"

<EditText
android:id="@+id/sub1"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:ems="10"
android:hint="Subject 1"
android:inputType="number"
android:textAlignment="center" />

<EditText
android:id="@+id/sub2"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:ems="10"
android:hint="Subject 2"
android:inputType="number"
android:textAlignment="center" />

<EditText
android:id="@+id/sub3"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:ems="10"
android:hint="Subject 3"
android:inputType="number"
android:textAlignment="center" />

</LinearLayout>

<Button
android:id="@+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"

37
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

app:layout_constraintEnd_toEndOf="parent"/>

<TextView
android:id="@+id/error"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Result"
android:textSize="25dp"/>

<TableLayout
android:id="@+id/tl"
android:layout_width="wrap_content"
android:layout_height="200dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.22"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/error"
app:layout_constraintVertical_bias="0.177">

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:text="Enrollment No : " />

<TextView android:id="@+id/disenroll" />


</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:text="Name : " />

<TextView android:id="@+id/disname" />


</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:text="Course : " />

<TextView android:id="@+id/discourse" />


</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:text="Semester : " />

<TextView android:id="@+id/dissem" />


</TableRow>

<TableRow
android:layout_width="match_parent"

38
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_height="match_parent">

<TextView android:text="Subject 1 : " />

<TextView android:id="@+id/dissub1" />


</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:text="Subject 2 : " />

<TextView android:id="@+id/dissub2" />


</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:text="Subject 3 : " />

<TextView android:id="@+id/dissub3" />


</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:text="Total : " />

<TextView android:id="@+id/distotal" />


</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:text="Percentage : " />

<TextView android:id="@+id/disper" />


</TableRow>

</TableLayout>

<Button
android:id="@+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Reset"
app:layout_constraintBaseline_toBaselineOf="@+id/submit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/submit" />

</[Link]>

39
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

➢ [Link]

public class MainActivity extends AppCompatActivity {

RadioButton bca,mca,bscit,mscit,bed,bba,mba,bcom,mcom,med;
RadioButton sem1,sem2,sem3,sem4,sem5,sem6;
Button submit,reset;
EditText enrno,name,sub1,sub2,sub3;
TextView disenroll,disname,discourse,dissem,dissub1,dissub2,dissub3,distotal,disper;
TextView error;
TableLayout tl;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

bca=(RadioButton) findViewById([Link]);
mca=(RadioButton) findViewById([Link]);
bscit=(RadioButton) findViewById([Link]);
mscit=(RadioButton) findViewById([Link]);
bed=(RadioButton) findViewById([Link]);

bba=(RadioButton) findViewById([Link]);
mba=(RadioButton) findViewById([Link]);
bcom=(RadioButton) findViewById([Link]);
mcom=(RadioButton) findViewById([Link]);
med=(RadioButton) findViewById([Link]);

sem1=(RadioButton) findViewById([Link].sem1);
sem2=(RadioButton) findViewById([Link].sem2);
sem3=(RadioButton) findViewById([Link].sem3);
sem4=(RadioButton) findViewById([Link].sem4);
sem5=(RadioButton) findViewById([Link].sem5);
sem6=(RadioButton) findViewById([Link].sem6);

enrno=(EditText) findViewById([Link]);
name=(EditText) findViewById([Link]);
sub1=(EditText) findViewById([Link].sub1);
sub2=(EditText) findViewById([Link].sub2);
sub3=(EditText) findViewById([Link].sub3);
submit=(Button) findViewById([Link]);
reset=(Button) findViewById([Link]);

error=(TextView) findViewById([Link]);
disenroll=(TextView) findViewById([Link]);
disname=(TextView) findViewById([Link]);
discourse=(TextView) findViewById([Link]);
dissem=(TextView) findViewById([Link]);
dissub1=(TextView) findViewById([Link].dissub1);
dissub2=(TextView) findViewById([Link].dissub2);
dissub3=(TextView) findViewById([Link].dissub3);
distotal=(TextView) findViewById([Link]);
disper=(TextView) findViewById([Link]);
tl=(TableLayout) findViewById([Link]);

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

40
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

[Link](false);
[Link](false);
[Link](false);
[Link](false);
[Link](false);
}
});

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

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

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

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

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

41
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

[Link](false);
}
});

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

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

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

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

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

42
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

[Link](false);
[Link](false);

[Link]("");
[Link]("");
[Link]("");
[Link]("");
[Link]("");
}
});

[Link](new [Link]() {
int counterr=0;
@Override
public void onClick(View view) {
//String err = [Link]().toString();
String enr = [Link]().toString();
String nm = [Link]().toString();
String s1 = [Link]().toString();
String s2 = [Link]().toString();
String s3 = [Link]().toString();
if ([Link]()) {
counterr++;
}
if ([Link]()) {
counterr++;
}
if ([Link]()) {
counterr++;
}
if ([Link]()) {
counterr++;
}
if ([Link]()) {
counterr++;
}

if([Link]()){
[Link]("BCA");
} else if ([Link]()) {
[Link]("MCA");
} else if ([Link]()) {
[Link]("BSCIT");
} else if ([Link]()) {
[Link]("MSCIT");
} else if ([Link]()) {
[Link]("BED");
} else if ([Link]()) {
[Link]("BBA");
} else if ([Link]()) {
[Link]("MBA");
} else if ([Link]()) {
[Link]("BCOM");
} else if ([Link]()) {
[Link]("MCOM");
} else if ([Link]()) {
[Link]("MED");
}else {
counter++;

43
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

if([Link]()){
[Link]("Semester 1");
} else if ([Link]()) {
[Link]("Semester 2");
} else if ([Link]()) {
[Link]("Semester 3");
} else if ([Link]()) {
[Link]("Semester 4");
} else if ([Link]()) {
[Link]("Semester 5");
} else if ([Link]()) {
[Link]("Semester 6");
} else {
counter++;
}

if(counterr == 0){
[Link]("Result");
[Link]([Link]("#1c2770"));
[Link]([Link]().toString());
[Link]([Link]().toString());
[Link]([Link]().toString());
[Link]([Link]().toString());
[Link]([Link]().toString());
Float subb1,subb2,subb3,sum,perce;
subb1 = [Link]([Link]().toString());
subb2 = [Link]([Link]().toString());
subb3 = [Link]([Link]().toString());

sum = subb1+subb2+subb3;
perce = (sum*100)/300;
[Link]([Link](sum));
[Link]([Link](perce));
}
else {
[Link]("Please Fill Properly");
[Link]([Link]("#ff0313"));
counterr=0;
}

}
});
}
}

 Output :

44
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

[Link] an application that designs a layout having options menu and 2 text
boxes for currency converter which allows user to select a particular
conversion from following options. a. Rupees to dollars b. dollars to Rupees c.
Rupees to pound d. Pound to Rupees e. The data for conversion should be
entered by the user in textbox. (Using Contextmenu)
➢ Activity_main.xml
<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" C"
android:textColor="#030842"
android:textSize="35dp"
android:textStyle="bold"
tools:layout_editor_absoluteX="150dp"
tools:layout_editor_absoluteY="28dp" />

<TextView
android:layout_width="wrap_content"

45
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

android:layout_height="wrap_content"
android:text="onverter"
android:textColor="#8c0f16"
android:textSize="30dp"
android:textStyle="bold"
tools:layout_editor_absoluteX="150dp"
tools:layout_editor_absoluteY="28dp" />

</LinearLayout>

<EditText
android:id="@+id/amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:ems="10"
android:hint="Enter Amount"
android:inputType="number"/>

<TableLayout
android:id="@+id/tableLayout"
android:layout_width="386dp"
android:layout_height="wrap_content"
android:layout_marginTop="52dp"

<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RadioButton
android:id="@+id/r1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rupees to Dollars"
android:textSize="18dp"
tools:layout_editor_absoluteX="322dp" />

<RadioButton
android:id="@+id/r2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:text="Dollars to Rupees"
android:textSize="18dp"
tools:layout_editor_absoluteX="322dp" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<RadioButton
android:id="@+id/r3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rupees to Pound"
android:textSize="18dp"
tools:layout_editor_absoluteX="322dp" />

46
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

<RadioButton
android:id="@+id/r4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:text="Pound to Rupees"
android:textSize="18dp"
tools:layout_editor_absoluteX="322dp" />
</TableRow>

</TableLayout>

<TextView
android:id="@+id/dis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:fontFamily="sans-serif"
android:text="TextView"
android:textColor="#1eb332"
android:textSize="30dp"/>

<Button
android:id="@+id/reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Reset"/>

</[Link]>

➢ [Link]
public class MainActivity extends AppCompatActivity {

RadioButton r1,r2,r3,r4;
Button reset;
TextView dis;
EditText amount;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

r1=(RadioButton) findViewById([Link].r1);
r2=(RadioButton) findViewById([Link].r2);
r3=(RadioButton) findViewById([Link].r3);
r4=(RadioButton) findViewById([Link].r4);
reset=(Button) findViewById([Link]);
dis=(TextView) findViewById([Link]);
amount=(EditText) findViewById([Link]);

[Link]("");
[Link](new [Link]() {
@Override
public void onClick(View view) {
String str = [Link]().toString();
if([Link]()){

47
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

[Link]("0");
}
Float a = [Link]([Link]().toString());
Float b = (a*12)/1000;
[Link]([Link](b));
[Link](false);
[Link](false);
[Link](false);
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
String str = [Link]().toString();
if([Link]()){
[Link]("0");
}
Float a = [Link]([Link]().toString());
Float b = (a*8272)/100;
[Link]([Link](b));
[Link](false);
[Link](false);
[Link](false);
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
String str = [Link]().toString();
if([Link]()){
[Link]("0");
}
Float a = [Link]([Link]().toString());
Float b = (a*96)/10000;
[Link]([Link](b));
[Link](false);
[Link](false);
[Link](false);
}
});

[Link](new [Link]() {
@Override
public void onClick(View view) {
String str = [Link]().toString();
if([Link]()){
[Link]("0");
}
Float a = [Link]([Link]().toString());
Float b = (a*10412)/100;
[Link]([Link](b));
[Link](false);
[Link](false);
[Link](false);
}
});

48
SYSTEM
Android PROBLEMSHEET - 1 SYSTEM

[Link](new [Link]() {
@Override
public void onClick(View view) {
[Link]("");
[Link](false);
[Link](false);
[Link](false);
[Link](false);
[Link]("");
}
});
}
}

 Output :

49
SYSTEM

You might also like