Mad Assign 11
Mad Assign 11
LAHORE.
Date: 17-4-25
4. Click Next
6. Name: MultiScreenApp
7. Language: Kotlin
9. Click Finish
setContentView(R.layout.activity_login)
STEP 3: Create 2 More Screens (Activities)
Create DashboardActivity:
Name: DashboardActivity
Click Finish
Create ProjectShowcaseActivity:
Name: ProjectShowcaseActivity
Click Finish
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="24dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/usernameEdit"
android:hint="Enter Username"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="@+id/passwordEdit"
android:hint="Enter Password"
android:inputType="textPassword"
android:layout_marginTop="12dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/loginBtn"
android:text="Login"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Open LoginActivity.kt
package com.example.multiscreenapp
import android.content.Intent
import android.os.Bundle
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
loginBtn.setOnClickListener {
val username = usernameEdit.text.toString()
val password = passwordEdit.text.toString()
<TextView
android:id="@+id/welcomeText"
android:textSize="20sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/projectBtn"
android:text="Go to Project Showcase"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Open DashboardActivity.kt
package com.example.multiscreenapp
import android.content.Intent
import android.os.Bundle
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
class DashboardActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_dashboard)
projectBtn.setOnClickListener {
val intent = Intent(this, ProjectShowcaseActivity::class.java)
startActivity(intent)
}
}
}
<LinearLayout
android:orientation="vertical"
android:padding="24dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:text="Project Title: Smart Farming App"
android:textStyle="bold"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="Description: An app that helps farmers monitor crops
using IoT and AI."
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="Features:"
android:textStyle="bold"
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="- Weather Monitoring\n- Crop Disease Detection\n-
Voice Alerts\n- IoT Sensor Integration"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:layout_marginTop="20dp"
android:src="@drawable/mockup"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="fitCenter" />
</LinearLayout>
</ScrollView>
Find an image for your project mockup then Rename it to: mockup.png
Open ProjectShowcaseActivity.kt
package com.example.multiscreenapp
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
class ProjectShowcaseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_project_showcase)
}
}
</application>