Professional Documents
Culture Documents
20BCR7107 Lab2
20BCR7107 Lab2
20BCR7107 Lab2
**********************************************************************************************************
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"
app:layout_constraintEnd_toStartOf="@+id/Total"
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
**********************************************************************************************************
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"
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"
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
**********************************************************************************************************
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"
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"
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
**********************************************************************************************************
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"
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"
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
**********************************************************************************************************
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"
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>
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
**********************************************************************************************************
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;
**********************************************************************************************************
});
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
**********************************************************************************************************
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
**********************************************************************************************************
XML code:
<TextView
android:id="@+id/textView"
android:layout_width="307dp"
android:layout_height="0dp"
android:layout_marginStart="46dp"
android:layout_marginTop="91dp"
android:layout_marginEnd="46dp"
android:layout_marginBottom="23dp"
android:text="CURRENCY CONVERTER"
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
**********************************************************************************************************
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"
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" />
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
**********************************************************************************************************
<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" />
<RadioButton
android:id="@+id/EURO"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:text="EURO" />
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
**********************************************************************************************************
<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"
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"
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
**********************************************************************************************************
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:
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;
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
**********************************************************************************************************
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
**********************************************************************************************************
}
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
**********************************************************************************************************