0% found this document useful (0 votes)
20 views56 pages

Print Androidpr

The document contains XML code for a layout that displays student data in a table with multiple rows. Each row contains the student's roll number, name, and marks percentage. There are 15 students listed in total with roll numbers ranging from 3306 to 3315 and marks from 89% to 98%.

Uploaded by

amarchavan096k
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)
20 views56 pages

Print Androidpr

The document contains XML code for a layout that displays student data in a table with multiple rows. Each row contains the student's roll number, name, and marks percentage. There are 15 students listed in total with roll numbers ranging from 3306 to 3315 and marks from 89% to 98%.

Uploaded by

amarchavan096k
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
You are on page 1/ 56

Amar Chavan

Practical No:5

1)
2)
Amar Chavan
Practical No:6
1)

<?xml version="1.0" encoding="utf-8"?>


<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TableRow
android:background="@color/teal_200"
android:layout_marginTop="10dp"
android:padding="5dp">

<TextView
android:text="Roll No"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Marks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>

<TableRow
android:background="#FFEB3B"
android:padding="5dp">

<TextView
android:text="3306"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Amar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="98%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>

<TableRow
android:background="#FFEB3B"
android:padding="5dp">
<TextView
android:text="3307"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Vaibhav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="97%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>

<TableRow
android:background="#FFEB3B"
android:padding="5dp">

<TextView
android:text="3308"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Suresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="96%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>

<TableRow
android:background="#FFEB3B"
android:padding="5dp">

<TextView
android:text="3309"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Mahesh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="95%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>

<TableRow
android:background="#FFEB3B"
android:padding="5dp">

<TextView
android:text="3310"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Narsh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="94%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>
<TableRow
android:background="#FFEB3B"
android:padding="5dp">

<TextView
android:text="3311"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Nilesh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="93%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>

<TableRow
android:background="#FFEB3B"
android:padding="5dp">

<TextView
android:text="3312"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Rakesh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="92%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>
<TableRow
android:background="#FFEB3B"
android:padding="5dp">

<TextView
android:text="3313"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Mukesh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="91%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>
<TableRow
android:background="#FFEB3B"
android:padding="5dp">

<TextView
android:text="3314"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Sunail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="90%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>

<TableRow
android:background="#FFEB3B"
android:padding="5dp">

<TextView
android:text="3315"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="Anil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
android:layout_weight="1"
/>
<TextView
android:text="89%"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="@color/black"
/>
</TableRow>

</TableLayout>
OP:-
2)
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:textSize="20dp"
android:textColor="@color/black"
android:textStyle="bold"
android:text="DataTypes In Object Orieanted Programming"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:textSize="20dp"
android:textColor="@color/black"
android:textStyle="bold"
android:text="Primitive DataType"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="120dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1)Integer"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2)Float"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3)Character"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4)Boolean"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="15dp"/>

</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:layout_gravity="right"
android:textSize="20dp"
android:textColor="@color/black"
android:textStyle="bold"
android:text="Non-Primitive DataType"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="right"
android:layout_marginTop="120dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1)Array"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2)Class"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3)Object"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4)Interface"
android:textColor="@color/black"
android:textStyle="bold"
android:textSize="15dp"/>

</LinearLayout>

</FrameLayout>
OP:-
Amar Chavan
Practical No:7
1)
2)
Amar Chavan
Practical No:8
1)
2)
Amar Chavan
Practical No:9
1)
2)

ActivityMain.XML

<?xml version="1.0" encoding="utf-8"?>


<AbsoluteLayout
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"
tools:context=".MainActivity"
tools:ignore="Deprecated">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="46dp"
android:layout_y="48dp"
android:textColor="@color/black"
android:textStyle="bold"
android:text="Simple Calculator"
android:textSize="40dp" />

<TextView
android:layout_width="199dp"
android:layout_height="40dp"
android:layout_x="17dp"
android:layout_y="129dp"
android:text="Enter First Number"
android:textColor="@color/black"
android:textSize="20dp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_x="27dp"
android:layout_y="275dp"
android:text="Result"
android:textColor="@color/black"
android:textSize="20dp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_x="16dp"
android:layout_y="206dp"
android:text="Enter Second Number"
android:textColor="@color/black"
android:textSize="20dp"
android:textStyle="bold" />

<EditText
android:id="@+id/firstNumberEditText"
android:layout_width="158dp"
android:layout_height="40dp"
android:layout_x="239dp"

android:layout_y="129dp"
android:inputType="number" />

<EditText
android:id="@+id/secondNumberEditText"
android:layout_width="158dp"
android:layout_height="40dp"
android:layout_x="244dp"
android:layout_y="207dp"
android:inputType="number" />

<EditText
android:id="@+id/resultEditText"
android:layout_width="158dp"
android:layout_height="40dp"
android:layout_x="243dp"
android:layout_y="276dp"
android:inputType="number"
android:editable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="13dp"
android:layout_y="377dp"
android:background="@color/purple_500"
android:text="+" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="120dp"
android:layout_y="378dp"
android:background="@color/purple_500"
android:text="-" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="223dp"
android:layout_y="376dp"
android:background="@color/purple_500"
android:text="*" />

<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="322dp"
android:layout_y="375dp"
android:background="@color/purple_500"
android:text="/" />

<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="165dp"
android:layout_y="452dp"
android:editable="false"
android:focusable="false"
android:background="@color/purple_500"
android:text="CLR" />

</AbsoluteLayout>

MainActivity.java
package com.example.pr92;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

private EditText firstNumberEditText, secondNumberEditText,


resultEditText;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
firstNumberEditText = findViewById(R.id.firstNumberEditText);
secondNumberEditText = findViewById(R.id.secondNumberEditText);
resultEditText = findViewById(R.id.resultEditText);
Button addButton = findViewById(R.id.button1);
Button subtractButton = findViewById(R.id.button2);
Button multiplyButton = findViewById(R.id.button3);
Button divideButton = findViewById(R.id.button4);

addButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
performOperation("+");
}
});

subtractButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
performOperation("-");
}
});

multiplyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
performOperation("*");
}
});

divideButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
performOperation("/");
}
});

Button clearButton = findViewById(R.id.button5);


clearButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
clearFields();
}
});
}

private void performOperation(String operator) {


try {
double num1 =
Double.parseDouble(firstNumberEditText.getText().toString());
double num2 =
Double.parseDouble(secondNumberEditText.getText().toString());
double result = 0;
switch (operator) {
case "+":
result = num1 + num2;
break;
case "-":
result = num1 - num2;
break;
case "*":
result = num1 * num2;
break;
case "/":
result = num1 / num2;
break;
}

resultEditText.setText(String.valueOf(result));
} catch (NumberFormatException e) {
// Handle invalid input
resultEditText.setText("Error");
}
}

private void clearFields() {


firstNumberEditText.getText().clear();
secondNumberEditText.getText().clear();
resultEditText.getText().clear();
}
}
Op:-
Amar Chavan
Practical No:10

1)
2)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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">

<ImageView
android:id="@+id/img1"
android:layout_width="356dp"
android:layout_height="188dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="@drawable/dyp" />

<EditText
android:id="@+id/i1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/img1"
android:layout_marginTop="15dp"
android:hint="Student Name"
/>

<EditText
android:id="@+id/i2"
android:layout_marginTop="15dp"
android:hint="Student Phone Number"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/i1"
/>

<EditText
android:id="@+id/i3"
android:layout_marginTop="15dp"
android:hint="Student Email id"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="@id/i2"
/>

<Button
android:id="@+id/i4"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/i3"
android:background="@color/purple_500"
android:text="Register User"/>

<TextView
android:id="@+id/i5"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/i4"
android:layout_margin="20dp"
/>

</RelativeLayout>

package com.example.pr102;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

private EditText studentNameEditText, phoneNumberEditText,


emailEditText;
private Button registerButton;
private TextView resultTextView;

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

studentNameEditText = findViewById(R.id.i1);
phoneNumberEditText = findViewById(R.id.i2);
emailEditText = findViewById(R.id.i3);
registerButton = findViewById(R.id.i4);
resultTextView = findViewById(R.id.i5);

registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

String studentName = studentNameEditText.getText().toString();


String phoneNumber = phoneNumberEditText.getText().toString();
String email = emailEditText.getText().toString();

if (isValidRegistration(studentName, phoneNumber, email)) {

resultTextView.setTextColor(Color.GREEN);
resultTextView.setText("Registration Successful!\nStudent Name:
" + studentName
+ "\nPhone Number: " + phoneNumber + "\nEmail: " + email);
} else {
resultTextView.setTextColor(Color.RED);
resultTextView.setText("Invalid Registration! Please check your
input.");
}
}

private boolean isValidRegistration(String studentName, String


phoneNumber, String email) {
return !studentName.isEmpty() && !phoneNumber.isEmpty() && !
email.isEmpty();
}
});
}
}
Amar Chavan
Practical No:11
Amar Chavan
Practical No:12

You might also like