Qazi Lab 3
Qazi Lab 3
Lab # 3
Submitted by
qazi
Submitted to
Department of BSIT-Morning
6th Semester
Page 1 of 6
Tasks:
<Button
android:id="@+id/textOneButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text One"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/textTwoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text Two"
android:layout_marginBottom="20dp" />
<Button
android:id="@+id/textThreeButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text Three" />
</LinearLayout>
Java code :
package com.example.lab3;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textOneButton.setOnClickListener(new View.OnClickListener() {
@Override
Page 2 of 6
public void onClick(View v) {
launchSecondActivity("Qazi");
}
});
textTwoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
launchSecondActivity("Jawad");
}
});
textThreeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
launchSecondActivity("Zaheer");
}
});
}
screenshot
Page 3 of 6
Xml 2nd code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="@android:color/black"
android:padding="16dp" />
</LinearLayout>
Java code:
package com.example.lab3;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
Page 4 of 6
screenshots after clicks:
Page 5 of 6
Page 6 of 6