Week 2 Answers
Week 2 Answers
tion process
Ans:
The lifecycle of an activity in the student registration process can be di-
vided into several stages. Here's a discussion on the typical lifecycle stages
of an activity in the student registration process:
1. OnCreate: This is the first callback method called after the activity is
created. Here, the activity initializes the user interface, sets up listen-
ers, and performs any initializations required for the registration
process.
4. OnPause: This method is called when the activity loses focus but re-
mains visible to the user. It allows the activity to pause ongoing opera-
tions, release resources, and save any necessary data.
It's important to note that the specific implementation and flow of the ac-
tivity lifecycle may vary depending on the programming framework or
platform being used, such as Android, web-based registration systems, or
desktop applications.
Step-2 : Once class files are created, we then create their respective xml
files for UI design activity_main.xml, activity_registration_list.xml and ac-
tivity_register.xml
Step-11 : Create a method called register having name and course as argu-
ments for inserting values in db and returns boolean flag based on the sta-
tus of the operation.
SplashActivity.kt
package com.example.courseregapp
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.os.Looper
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Handler(Looper.getMainLooper()).postDelayed({
startActivity(Intent(this, RegisteredList::class.java))
}, 3000)
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".SplashActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Material3.HeadlineLarge"
android:textStyle="bold"
android:gravity="center"
android:elegantTextHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
DBHandler.kt
package com.example.courseregapp
import android.content.ContentValues
import android.content.Context
import android.database.Cursor
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
class DBHandler(context: Context, factory: SQLiteDatabase.CursorFactory?) :
db.execSQL(query)
onCreate(db)
values.put(NAME_COl, name)
values.put(COURSE_COL, course)
val db = this.writableDatabase
val value = db.insert(TABLE_NAME, null, values).toInt()
db.close()
return value != -1
val db = this.readableDatabase
val db = this.writableDatabase
db.close()
return status != 0
companion object{
}
}
ListItemModel.kt
package com.example.courseregapp
data class ListItemModel(var id: Int, var name: String, var course: String)
RegisteredList.kt
package com.example.courseregapp
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.courseregapp.databinding.ActivityRegistrationListBinding
super.onCreate(savedInstanceState)
mBinding = ActivityRegistrationListBinding.inflate(layoutInflater)
setContentView(mBinding.root)
initViews()
mBinding.apply {
rvView.layoutManager = LinearLayoutManager(this@RegisteredList)
btnRegister.setOnClickListener {
startActivity(Intent(this@RegisteredList, RegisterActivity::class.java))
cursor?.let {
if (list.isNotEmpty())
list.clear()
while(it.moveToNext()) {
populateView()
mBinding.rvView.adapter = adapter
if (dbHandler.deleteRecord(id)) {
if (list.isNotEmpty()) {
list.removeAt(pos)
adapter?.notifyItemRemoved(pos)
adapter?.notifyItemRangeChanged(pos, list.size)
mBinding.rvView.adapter = adapter
} else {
activity_registration_list.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rlt_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".RegisteredList">
<TextView
android:id="@+id/tv_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textAppearance="@style/TextAppearance.Material3.HeadlineLarge"
android:textStyle="bold"
android:text="Enrolled Students"
android:textColor="@color/white"
android:elevation="10dp"
android:background="@color/dark_blue"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_view"
android:layout_above="@+id/btn_register"
android:background="@color/gray"
android:scrollbars="vertical"
android:overScrollMode="always"
tools:listitem="@layout/activity_list_row"
tools:itemCount="2"/>
<Button
android:id="@+id/btn_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="5dp"
android:padding="16dp"
android:text="Register"/>
</RelativeLayout>
RecyclerAdapter.kt
package com.example.courseregapp
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
return ViewHolder(view)
holder.let {
it.tvName.text = mList[position].name
it.tvCourse.text = mList[position].course
it.btnDelete.setOnClickListener {
listener.onItemClickListener(mList[position].id, position)
interface RowClickListener {
}
activity_list_row.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardElevation="6dp">
<RelativeLayout
android:id="@+id/rlt_sub_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_centerVertical="true"
android:layout_alignParentStart="true"
android:textColor="@color/black"
android:text="001"
android:textSize="20sp"/>
<LinearLayout
android:id="@+id/llt_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_toEndOf="@id/tv_id"
android:layout_toStartOf="@id/btn_delete"
android:orientation="vertical">
<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:ellipsize="end"
android:maxLines="1"
android:text="ARUN SIVANANDAN"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_course"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:ellipsize="end"
android:maxLines="2"
android:text="BCA"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
<Button
android:id="@+id/btn_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_alignBottom="@id/llt_container"
android:layout_marginEnd="5dp"
android:text="Delete"
android:textColor="@color/white"
android:textStyle="bold"
android:backgroundTint="@color/red" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
RegisterActivity.kt
package com.example.courseregapp
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ArrayAdapter
import android.widget.Toast
import com.example.courseregapp.databinding.ActivityRegisterBinding
class RegisterActivity : AppCompatActivity() {
DBHandler(this, null)
super.onCreate(savedInstanceState)
mBinding = ActivityRegisterBinding.inflate(layoutInflater)
setContentView(mBinding.root)
initViews();
mBinding.apply {
acTv.setAdapter(adapter)
btnSubmit.setOnClickListener {
if (dbHandler.register(edtName.text.toString(), acTv.text.toString())) {
finish()
} else {
Toast.makeText(this@RegisterActivity, "Insertion Failed. Try again!",
Toast.LENGTH_SHORT).show()
activity_register.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".RegisterActivity">
<TextView
android:id="@+id/tv_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dark_blue"
android:elevation="10dp"
android:padding="16dp"
android:text="Register Course"
android:textAppearance="@style/TextAppearance.Material3.HeadlineLarge"
android:textColor="@color/white"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:boxBackgroundMode="outline"
app:boxCornerRadiusBottomEnd="16dp"
app:boxCornerRadiusBottomStart="16dp"
app:boxCornerRadiusTopEnd="16dp"
app:boxCornerRadiusTopStart="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_view">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edt_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/dark_blue"
android:textColorHint="@color/black" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_dropdown"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:boxBackgroundMode="outline"
app:boxCornerRadiusBottomEnd="16dp"
app:boxCornerRadiusBottomStart="16dp"
app:boxCornerRadiusTopEnd="16dp"
app:boxCornerRadiusTopStart="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textInputLayout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense.Exposed-
DropdownMenu">
<com.google.android.material.textfield.MaterialAutoCompleteTextView
android:id="@+id/ac_tv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="@color/dark_blue"/>
</com.google.android.material.textfield.TextInputLayout>
<Button
android:id="@+id/btn_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:padding="16dp"
android:text="Submit"
android:textSize="18sp"
android:textColor="@color/white"
android:backgroundTint="@color/dark_blue"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/til_dropdown" />
</ androidx.constraintlayout.widget.ConstraintLayout>
Out- put:
3. Create an android application for simple basic calcula-
tor.
Ans: A basic simple calculator android application has been created using
kotlin. Below mentioned are the class and layout files with output screen-
shots for reference.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CalcApp"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
</application>
</manifest>
activity_calculator.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="data"
type="com.example.calcapp.DataModel" />
<variable
name="activity"
type="com.example.calcapp.MainActivity" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@id/tabLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/textview_calculate_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="textEnd"
android:textSize="@dimen/text_size_normal"
android:text="@{data.calculateBefore}"
android:textColor="@android:color/darker_gray"
android:maxLines="1" />
<TextView
android:id="@+id/textview_calculate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="textEnd"
android:textSize="@dimen/text_size_large"
android:text="@{data.calculate}"
android:textColor="@color/white"
android:maxLines="1"/>
</LinearLayout>
<TableLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/orange"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TableRow
android:id="@+id/tr_one"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:weightSum="4">
<Button
android:id="@+id/button_clear"
android:onClick="@{activity.onClickAction}"
android:text="@string/clear"
android:textAllCaps="true"
style="@style/Btn_Left"/>
<ImageButton
android:id="@+id/button_backspace"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_weight="1"
android:layout_marginStart="@dimen/margin"
android:src="@drawable/ic_baseline_backspace_24"
android:onClick="@{activity.onClickAction}"
android:background="?attr/colorPrimary"
style="@style/Widget.AppCompat.Button"/>
<Button
android:id="@+id/button_percentage"
android:text="@string/percentage"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left"/>
<Button
android:id="@+id/button_divide"
android:text="@string/divide"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Right"/>
</TableRow>
<TableRow
android:id="@+id/tr_two"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:weightSum="4">
<Button
android:id="@+id/button_seven"
android:text="@string/seven"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left"/>
<Button
android:id="@+id/button_eight"
android:text="@string/eight"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left" />
<Button
android:id="@+id/button_nine"
android:text="@string/nine"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left"/>
<Button
android:id="@+id/button_multiply"
android:text="@string/multiply"
android:textAllCaps="false"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Right"/>
</TableRow>
<TableRow
android:id="@+id/tr_three"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:weightSum="4">
<Button
android:id="@+id/button_four"
android:text="@string/four"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left"/>
<Button
android:id="@+id/button_five"
android:text="@string/five"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left"/>
<Button
android:id="@+id/button_six"
android:text="@string/six"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left"/>
<Button
android:id="@+id/button_subtract"
android:text="@string/subtract"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Right"/>
</TableRow>
<TableRow
android:id="@+id/tr_four"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:gravity="center"
android:weightSum="4">
<Button
android:id="@+id/button_one"
android:text="@string/one"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left"/>
<Button
android:id="@+id/button_two"
android:text="@string/two"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left"/>
<Button
android:id="@+id/button_three"
android:text="@string/three"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Left"/>
<Button
android:id="@+id/button_add"
android:text="@string/add"
android:onClick="@{activity.onClickAction}"
style="@style/Btn_Right"/>
</TableRow>
<TableRow
android:id="@+id/tr_five"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin"
android:weightSum="3">
<Button
android:id="@+id/button_dot"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_weight=".74"
android:layout_marginStart="@dimen/margin"
android:background="?attr/colorPrimary"
android:textColor="@color/white"
android:text="@string/dot"
android:textSize="@dimen/text_size_small"
android:onClick="@{activity.onClickAction}" />
<Button
android:id="@+id/button_zero"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_weight=".75"
android:layout_marginStart="@dimen/margin"
android:background="?attr/colorPrimary"
android:textColor="@color/white"
android:text="@string/zero"
android:textSize="@dimen/text_size_small"
android:onClick="@{activity.onClickAction}" />
<Button
android:id="@+id/button_equalTo"
android:layout_width="@dimen/width"
android:layout_height="@dimen/height"
android:layout_weight="1.51"
android:layout_marginStart="@dimen/margin"
android:layout_marginEnd="@dimen/margin"
android:background="?attr/colorPrimary"
android:textColor="@color/white"
android:text="@string/equalTo"
android:textSize="@dimen/text_size_small"
android:textAllCaps="false"
android:onClick="@{activity.onClickAction}" />
</TableRow>
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
MainActivity.xml
package com.example.calcapp
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import androidx.databinding.DataBindingUtil
import com.example.calcapp.databinding.ActivityCalculatorBinding
DataModel("", "")
super.onCreate(savedInstanceState)
binding.apply {
activity = this@MainActivity
data = dataModel
// textviewCalculate.setHorizontallyScrolling(true)
// textviewCalculate.movementMethod = ScrollingMovementMethod()
}
onLongClickListenerAction()
when (view.id) {
R.id.button_clear -> {
clearData()
binding.data = dataModel
R.id.button_backspace -> {
if (dataModel.calculate.length > 1)
else
dataModel.calculate = ""
binding.data = dataModel
R.id.button_equalTo -> {
addValues()
if (isAdd)
dataModel.calculateBefore = "$valueOne+$valueTwo"
else if (isSubtract)
dataModel.calculateBefore = "$valueOne-$valueTwo"
else if (isDivide)
else if (isMultiply)
dataCalculate()
binding.data = dataModel
dataModel.apply {
when (value) {
getString(R.string.add) -> {
if (isShowAnswer) {
calculateBefore = ""
valueOne = ""
valueTwo = ""
isShowAnswer = false
return
if (calculate.isNotEmpty()) {
isAdd = true
addValues()
calculateBefore = "$valueOne+$valueTwo"
calculate = ""
getString(R.string.subtract) -> {
if (isShowAnswer) {
calculateBefore = ""
valueOne = ""
valueTwo = ""
isShowAnswer = false
calculate = calculate.plus(value)
calculate = calculate.plus(value)
isSubtract = true
addValues()
calculateBefore = "$valueOne-$valueTwo"
calculate = ""
getString(R.string.multiply) -> {
if (isShowAnswer) {
calculateBefore = ""
valueOne = ""
valueTwo = ""
isShowAnswer = false
return
if (calculate.isNotEmpty()) {
isMultiply = true
addValues()
calculate = ""
getString(R.string.divide) -> {
if (isShowAnswer) {
calculateBefore = ""
valueOne = ""
valueTwo = ""
isShowAnswer = false
return
if (calculate.isNotEmpty()) {
isDivide = true
addValues()
calculate = ""
getString(R.string.percentage) -> {
if (isShowAnswer) {
calculateBefore = ""
valueOne = ""
valueTwo = ""
isShowAnswer = false
return
if (calculate.isNotEmpty()) {
isPercentage = true
addValues()
calculateBefore = "$valueOne%$valueTwo"
calculate = ""
} else -> {
calculate = calculate.plus(value)
binding.data = this
dataModel.apply {
if (calculate.isNotEmpty()) {
if (valueOne.isEmpty()) {
valueOne = calculate
} else {
valueTwo = calculate
dataModel.apply {
numOne = if (valueOne.length == 2) {
valueOne.substring(1).toDouble()
} else {
valueOne.substring(1, valueOne.length).toDouble()
}
numTwo = if (valueTwo.length == 2) {
valueTwo.substring(1).toDouble()
} else {
valueTwo.substring(1, valueTwo.length).toDouble()
if (isAdd) {
} else if (isSubtract) {
} else if (isMultiply) {
} else if (isDivide) {
} else if (isPercentage) {
numOne = if (valueOne.length == 2) {
valueOne.substring(1).toDouble()
} else {
valueOne.substring(1, valueOne.length).toDouble()
valueTwo.substring(0, valueTwo.length).toDouble()
} else {
valueTwo.substring(0).toDouble()
if (isAdd) {
} else if (isMultiply) {
} else if (isDivide) {
} else if (isPercentage) {
valueOne.substring(0, valueOne.length).toDouble()
} else {
valueOne.substring(0).toDouble()
numTwo = if (valueTwo.length == 2) {
valueTwo.substring(1).toDouble()
} else {
valueTwo.substring(1, valueTwo.length).toDouble()
if (isAdd) {
} else if (isSubtract) {
} else if (isMultiply) {
} else if (isDivide) {
} else if (isPercentage) {
} else {
valueOne.substring(0, valueOne.length).toDouble()
else
valueOne.substring(0).toDouble()
valueTwo.substring(0, valueTwo.length).toDouble()
else
valueTwo.substring(0).toDouble()
if (isAdd) {
} else if (isSubtract) {
} else if (isMultiply) {
} else if (isDivide) {
} else if (isPercentage) {
} else {
total.toString()
} else {
total.toInt().toString()
isShowAnswer = true
isAdd = false
isSubtract = false
isMultiply = false
isDivide = false
isPercentage = false
binding.data = this
valueOne = ""
valueTwo = ""
dataModel.apply {
calculateBefore = ""
calculate = ""
valueOne = ""
valueTwo = ""
binding.buttonBackspace.setOnLongClickListener {
clearData()
binding.data = dataModel
true
Output :