rm11


Q1]
ActivityMain.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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/collegeNameTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Modern chutya ahe !"
        android:textSize="20sp"
        android:textStyle="bold"
        android:textColor="@android:color/black"
        android:layout_centerInParent="true"/>

    <Button
        android:id="@+id/changeColorButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Change Color"
        android:layout_below="@id/collegeNameTextView"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="20dp"/>
</RelativeLayout>

</androidx.constraintlayout.widget.ConstraintLayout>


ActivityMain.java
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

private TextView collegeNameTextView;
private Button changeColorButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    collegeNameTextView = findViewById(R.id.collegeNameTextView);
    changeColorButton = findViewById(R.id.changeColorButton);

    changeColorButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Change text color to red
            collegeNameTextView.setTextColor(Color.RED);

            // Change font size to 24sp and style to italic
            collegeNameTextView.setTextSize(24);
            collegeNameTextView.setTypeface(null, Typeface.ITALIC);
        }
    });
}

}


Q2]

ActivityMain.java

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

private EditText firstNameEditText, middleNameEditText, lastNameEditText;
private EditText dobEditText, addressEditText, emailEditText;
private Button submitButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    firstNameEditText = findViewById(R.id.firstNameEditText);
    middleNameEditText = findViewById(R.id.middleNameEditText);
    lastNameEditText = findViewById(R.id.lastNameEditText);
    dobEditText = findViewById(R.id.dobEditText);
    addressEditText = findViewById(R.id.addressEditText);
    emailEditText = findViewById(R.id.emailEditText);
    submitButton = findViewById(R.id.submitButton);

    submitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String firstName = firstNameEditText.getText().toString();
            String middleName = middleNameEditText.getText().toString();
            String lastName = lastNameEditText.getText().toString();
            String dob = dobEditText.getText().toString();
            String address = addressEditText.getText().toString();
            String email = emailEditText.getText().toString();

            // Start Second Activity and pass data
            Intent intent = new Intent(MainActivity.this, MainActivity.class);
            intent.putExtra("firstName", firstName);
            intent.putExtra("middleName", middleName);
            intent.putExtra("lastName", lastName);
            intent.putExtra("dob", dob);
            intent.putExtra("address", address);
            intent.putExtra("email", email);
            startActivity(intent);
        }
    });

    // Retrieve data from Intent and display in TextViews
    Intent intent = getIntent();
    if (intent != null) {
        String firstName = intent.getStringExtra("firstName");
        String middleName = intent.getStringExtra("middleName");
        String lastName = intent.getStringExtra("lastName");
        String dob = intent.getStringExtra("dob");
        String address = intent.getStringExtra("address");
        String email = intent.getStringExtra("email");

        TextView firstNameTextView = findViewById(R.id.firstNameTextView);
        TextView middleNameTextView = findViewById(R.id.middleNameTextView);
        TextView lastNameTextView = findViewById(R.id.lastNameTextView);
        TextView dobTextView = findViewById(R.id.dobTextView);
        TextView addressTextView = findViewById(R.id.addressTextView);
        TextView emailTextView = findViewById(R.id.emailTextView);

        // Display data in TextViews
        firstNameTextView.setText("First Name: " + firstName);
        middleNameTextView.setText("Middle Name: " + middleName);
        lastNameTextView.setText("Last Name: " + lastName);
        dobTextView.setText("Date of Birth: " + dob);
        addressTextView.setText("Address: " + address);
        emailTextView.setText("Email ID: " + email);
    }
}

}

ActivityMain.xml

<?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:padding="16dp" tools:context=".MainActivity">

<EditText
    android:id="@+id/firstNameEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="First Name" />

<EditText
    android:id="@+id/middleNameEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Middle Name" />

<EditText
    android:id="@+id/lastNameEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Last Name" />

<EditText
    android:id="@+id/dobEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Date of Birth" />

<EditText
    android:id="@+id/addressEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Address" />

<EditText
    android:id="@+id/emailEditText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Email ID" />

<Button
    android:id="@+id/submitButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Submit" />

<TextView
    android:id="@+id/firstNameTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp" />

<TextView
    android:id="@+id/middleNameTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp" />

<TextView
    android:id="@+id/lastNameTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp" />

<TextView
    android:id="@+id/dobTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp" />

<TextView
    android:id="@+id/addressTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp" />

<TextView
    android:id="@+id/emailTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp" />
</LinearLayout>