Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

VIT-AP UNIVERSITY, ANDHRA PRADESH

Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163

**********************************************************************************************************

Lab2:
1. Design the following APP for the IOT store. The cost of Aurdino Uno is 500RS, the cost of WIFI module is
250RS and the Bluetooth module is 200RS. Based on the quantity compute the Amount payable when
submit button is clicked, When clear is clicked clear all the Editboxes.

XML code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
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/textView7"
android:layout_width="103dp"
android:layout_height="59dp"
android:layout_marginStart="35dp"
android:layout_marginLeft="35dp"
android:layout_marginBottom="151dp"
android:text="Total" android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


app:layout_constraintEnd_toStartOf="@+id/Total"
app:layout_constraintStart_toStartOf="parent"
****************************************************************
******************************************

app:layout_constraintTop_toBottomOf="@+id/button" />
<TextView
android:id="@+id/textView6"
android:layout_width="130dp"
android:layout_height="43dp"
android:layout_marginStart="36dp"
android:layout_marginLeft="36dp"
android:layout_marginBottom="48dp"
android:text="Bluetooth"
android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@+id/button"
app:layout_constraintEnd_toStartOf="@+id/Bluetooth"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView5" />
<TextView
android:id="@+id/textView5"
android:layout_width="131dp"
android:layout_height="39dp"
android:layout_marginStart="36dp"
android:layout_marginLeft="36dp"
android:layout_marginBottom="28dp"
android:text="Wifi Module"
android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@+id/textView6"
app:layout_constraintEnd_toStartOf="@+id/WifiModule"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView4" />
<TextView
android:id="@+id/textView3"
android:layout_width="129dp"
android:layout_height="37dp"
android:layout_marginTop="141dp"
android:layout_marginEnd="61dp"
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


android:layout_marginRight="61dp"
android:layout_marginBottom="31dp"
android:text="Quantity"
android:textSize="25sp"
app:layout_constraintBottom_toTopOf="@+id/Aurdino"
app:layout_constraintEnd_toEndOf="parent"
***************************************************************************************************
*******

app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="129dp"
android:layout_height="37dp"
android:layout_marginStart="36dp"
android:layout_marginLeft="36dp"
android:layout_marginTop="141dp"
android:layout_marginEnd="56dp"
android:layout_marginRight="56dp"
android:layout_marginBottom="32dp"
android:text="Items"
android:textSize="25sp"
app:layout_constraintBottom_toTopOf="@+id/textView4"
app:layout_constraintEnd_toStartOf="@+id/textView3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView4"
android:layout_width="130dp"
android:layout_height="40dp"
android:layout_marginStart="36dp"
android:layout_marginLeft="36dp"
android:layout_marginBottom="28dp"
android:text="Aurdino Uno"
android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@+id/textView5"
app:layout_constraintEnd_toStartOf="@+id/Aurdino"
app:layout_constraintStart_toStartOf="parent"
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


app:layout_constraintTop_toBottomOf="@+id/textView" />
<EditText android:id="@+id/Aurdino"
android:layout_width="wrap_content"
android:layout_height="wrap_content
" android:layout_marginEnd="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="19dp"
android:ems="10"
********************************************
********************************************
******************

android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/WifiModule"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView4"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<EditText
android:id="@+id/WifiModule"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="27dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toTopOf="@+id/Bluetooth"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView5"
app:layout_constraintTop_toBottomOf="@+id/Aurdino" />
<EditText
android:id="@+id/Bluetooth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="46dp"
android:ems="10"
android:inputType="textPersonName"
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


app:layout_constraintBottom_toTopOf="@+id/button2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView6"
app:layout_constraintTop_toBottomOf="@+id/WifiModule" />
<EditText android:id="@+id/Total"
android:layout_width="wrap_content"
android:layout_height="wrap_content
" android:layout_marginTop="5dp"
android:layout_marginEnd="30dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="158dp
"
*********************************************
*********************************************
****************

android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView7"
app:layout_constraintTop_toBottomOf="@+id/button2" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="75dp"
android:layout_marginLeft="75dp"
android:layout_marginEnd="43dp"
android:layout_marginRight="43dp"
android:layout_marginBottom="44dp"
android:text="Submit"
app:layout_constraintBottom_toTopOf="@+id/textView7"
app:layout_constraintEnd_toStartOf="@+id/button2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView6" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


android:layout_height="wrap_content"
android:layout_marginEnd="107dp"
android:layout_marginRight="107dp"
android:layout_marginBottom="44dp"
android:text="Clear"
app:layout_constraintBottom_toTopOf="@+id/Total"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/button"
app:layout_constraintTop_toBottomOf="@+id/Bluetooth" />

</android.support.constraint.ConstraintLayout>
********************************************************************************************************
**

Mainactivity code:
package com.example.iotstore;

import
android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import
android.view.View; import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {


EditText Aurdino,WifiModule,Bluetooth,Total;
Button button,button2;
View textView,textView1,textView3,textView5,textView6,textView7,textView4;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
textView3 = findViewById(R.id.textView3);
textView5 = findViewById(R.id.textView5);
textView6 = findViewById(R.id.textView6);
textView7 = findViewById(R.id.textView7);
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


textView4 = findViewById(R.id.textView4);
Aurdino = findViewById(R.id.Aurdino);
WifiModule = findViewById(R.id.WifiModule);
Bluetooth = findViewById(R.id.Bluetooth);
Total = findViewById(R.id.Total); button = findViewById(R.id.button); button2
= findViewById(R.id.button2);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int result =
500*Integer.parseInt(String.valueOf(Aurdino.getText()))
+250*Integer.parseInt(String.valueOf(WifiModule.getText()))
+200*Integer.parseInt(String.valueOf(Bluetooth.getText()));
Total.setText(String.valueOf(result));
}
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163

**********************************************************************************************************

});
button2.setOnClickListener(new View.OnClickListener() {
@Override public
void onClick(View v) {
Aurdino.setText("");
WifiModule.setText("");
Bluetooth.setText("");
Total.setText("");
}
});
}}

AS WINDOW:

OUTPUT: **********************************************************************************************************
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163

**********************************************************************************************************

2.Design a Currency converter App

XML code:

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


<android.support.constraint.ConstraintLayout
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/textView"
android:layout_width="307dp"
android:layout_height="0dp"
android:layout_marginStart="46dp"
android:layout_marginTop="91dp"
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


android:layout_marginEnd="46dp"
android:layout_marginBottom="23dp"
android:text="CURRENCY CONVERTER"
*************************************************
*************************************************
********

android:textColor="#4CAF50"
android:textSize="25sp"

app:layout_constraintBottom_toTopOf="@+id/rupeeValue"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<EditText
android:id="@+id/rupeeValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:layout_marginBottom="484dp"
android:ems="10" android:hint="in rs"

android:inputType="textPersonName"
android:minHeight="48dp"
app:layout_constraintBottom_toBottomOf="parent"
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.447"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="1.0" />
*******************************************************************************
***************************

<RadioGroup android:id="@+id/radioGroup2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="18dp"
android:layout_marginBottom="31dp"
app:layout_constraintBottom_toTopOf="@+id/button2"
app:layout_constraintStart_toStartOf="@+id/rupeeValue"
app:layout_constraintTop_toBottomOf="@+id/rupeeValue">

<RadioButton
android:id="@+id/USD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:text="USD" />
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


<RadioButton
android:id="@+id/EURO"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:text="EURO" />
****************************************************
****************************************************
**

<RadioButton
android:id="@+id/YEN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:text="YEN" />

</RadioGroup>

<EditText android:id="@+id/convertedValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="92dp"
android:ems="10"
android:inputType="textPersonName"
android:minHeight="48dp"
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button2"
tools:ignore="SpeakableTextPresentCheck" />

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

android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:layout_marginBottom="51dp"
android:text="CONVERT"
app:layout_constraintBottom_toTopOf="@+id/convertedValue"
app:layout_constraintStart_toStartOf="@+id/radioGroup2"
app:layout_constraintTop_toBottomOf="@+id/radioGroup2"

</android.support.constraint.ConstraintLayout>

Mainactivity code:
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


package com.example.converter;

import
android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import
android.view.View; import android.widget.Button;
import android.widget.EditText; import
android.widget.RadioButton; import
android.widget.RadioGroup;
**********************************************************
************************************************

public class MainActivity extends AppCompatActivity {


EditText rupeeValue,convertedValue;
Button b1;
RadioGroup rg;
RadioButton r1; @Override protected void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rupeeValue=findViewById(R.id.rupeeValue);
convertedValue=findViewById(R.id.convertedValue);
b1=findViewById(R.id.button2);
rg=findViewById(R.id.radioGroup2);
b1.setOnClickListener(new View.OnClickListener() {
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163


@Override public void
onClick(View v) { int
i=rg.getCheckedRadioButtonId();
r1=findViewById(i);
if(r1.getText().equals("USD")){

double
convertedCurrencyValue=Integer.parseInt(rupeeValue.getText().toString())*0.014
;

convertedValue.setText(String.valueOf(convertedCurrencyValue));
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163

**********************************************************************************************************

}
else if(r1.getText().equals("EURO")){
double

convertedCurrencyValue=Integer.parseInt(rupeeValue.getText().toString())*0.011
;

convertedValue.setText(String.valueOf(convertedCurrencyValue));
}
else if(r1.getText().equals("YEN")){
double

convertedCurrencyValue=Integer.parseInt(rupeeValue.getText().toString())*1.44;

convertedValue.setText(String.valueOf(convertedCurrencyValue));
}
}
});
}}

Output:

**********************************************************************************************************
VIT-AP UNIVERSITY, ANDHRA PRADESH
Lab Sheet 2 : EditText and RadioButon

Academic year: 2021-2022 Branch/ Class: B.Tech


Semester: Fall Date: 17/09/22
Faculty Name: Dr.N.Anupama School: SCOPE

NAME: Mithun jogi R REGNO:20BCE7163

You might also like