Amp 31 03 2022

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Q1.

ANDROID RESOURCES

<?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=".MainActivity">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.136" />

<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/letter" />

</androidx.constraintlayout.widget.ConstraintLayout>

Q2. ACTIVITY LIFE CYCLE


package com.example.lifecycle

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

class MainActivity : AppCompatActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}

override fun onStart() {


super.onStart()
Toast.makeText(context:.this,text"on
start",Toast.Length_Long).show();
}

override fun onPause() {


super.onPause()
Toast.makeText(context:.this,text"on
Pause",Toast.Length_Long).show();
}

override fun onResume() {


super.onResume()
Toast.makeText(context:.this,text"on
resume",Toast.Length_Long).show();
}

override fun onRestart() {


super.onRestart()
Toast.makeText(context:.this,text"on
Restart",Toast.Length_Long).show();
}
override fun onDestroy() {
super.onDestroy()
Toast.makeText(context:.this,text"on
Destroy",Toast.Length_Long).show();
}
}

You might also like