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

Saba-788 Mobile App Color Change Code

This document is an assignment submission for the course IT-332: Mobile Application Development by students Manoor Laiqat, Arjumand Naz, and Saba. It includes a Kotlin code for an Android application that changes the background color of a layout between pink and white when a button is clicked. The XML layout defines the user interface with a button to trigger the color change.

Uploaded by

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

Saba-788 Mobile App Color Change Code

This document is an assignment submission for the course IT-332: Mobile Application Development by students Manoor Laiqat, Arjumand Naz, and Saba. It includes a Kotlin code for an Android application that changes the background color of a layout between pink and white when a button is clicked. The XML layout defines the user interface with a button to trigger the color change.

Uploaded by

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

ASSIGNMENT # 01

SUBMITTED BY:
MANOOR LAIQAT (770 – FOC/BSIT/F22)
ARJUMAND NAZ (740 – FOC/BSIT/F22)
SABA (788– FOC/BSIT/F22)

COURSE CODE:
IT – 332

COURSE TITLE:
MOBILE APPLICATION DEVELOPMENT

SUBMITTED TO:
MA’AM SYEDA AMMARA
[Link]

package [Link]
import [Link]
import [Link]
import [Link]
import [Link]
import
[Link]

class MainActivity : AppCompatActivity() {


private var isOriginalColor = true // Track the
current color state
override fun onCreate(savedInstanceState:
Bundle?) {
[Link](savedInstanceState)
setContentView([Link].activity_main)

// Find views
val mainLayout =
findViewById<ConstraintLayout>([Link]) // Layout
val buttonChangeColor =
findViewById<Button>([Link].button_id) // Button

// Handle button click


[Link] {
if (isOriginalColor) {

[Link]([Link]("#FFC0
CB")) // Change to PINK
} else {

[Link]([Link]) // Change
back to original (WHITE)
}
isOriginalColor = !isOriginalColor //
Toggle state
}
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<[Link]

xmlns:android="[Link]
roid"
xmlns:app="[Link]
auto"
xmlns:tools="[Link]
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
tools:context=".MainActivity">
<!-- Button to change color -->
<Button
android:id="@+id/button_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Color"
android:textColor="#FFFFFF"
android:backgroundTint="#800080"

app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"

app:layout_constraintRight_toRightOf="parent"/>
</[Link]>

You might also like