Android
Android
Android
Feedback Form
→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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="274dp"
android:layout_height="41dp"
android:text="Feedback Form"
android:textColor="#000000"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.496"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.04" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ratings"
android:textColor="#000000"
android:textSize="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.104"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.017" />
<RadioGroup
android:id="@+id/rg"
android:layout_width="146dp"
android:layout_height="200dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.105"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.0">
<RadioButton
android:id="@+id/rb1"
android:layout_width="123dp"
android:layout_height="wrap_content"
android:text="Excellent"
android:textSize="20dp" />
<RadioButton
android:id="@+id/rb2"
android:layout_width="127dp"
android:layout_height="wrap_content"
android:text="Good"
android:textSize="20dp" />
<RadioButton
android:id="@+id/rb3"
android:layout_width="123dp"
android:layout_height="wrap_content"
android:text="Ok"
android:textSize="20dp" />
<RadioButton
android:id="@+id/rb4"
android:layout_width="121dp"
android:layout_height="wrap_content"
android:text="Poor"
android:textSize="20dp" />
</RadioGroup>
<TextView
android:id="@+id/textView3"
android:layout_width="378dp"
android:layout_height="50dp"
android:background="#00E1CECE"
android:text="Give Your Few Suggeotion here"
android:textColor="#000000"
android:textSize="25dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.848"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rg"
app:layout_constraintVertical_bias="0.035" />
<CheckBox
android:id="@+id/cb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I really enjoy this seminar."
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.133"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3"
app:layout_constraintVertical_bias="0.0" />
<CheckBox
android:id="@+id/cb2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I will perfer this seminar to else also."
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.186"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cb1"
app:layout_constraintVertical_bias="0.061" />
<CheckBox
android:id="@+id/cb3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I would like to here more form you"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.168"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cb2"
app:layout_constraintVertical_bias="0.084" />
<CheckBox
android:id="@+id/cb4"
android:layout_width="376dp"
android:layout_height="48dp"
android:text="I am satisfied with the contant and full descripon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cb3"
app:layout_constraintVertical_bias="0.192"
tools:ignore="TouchTargetSizeCheck" />
<Button
android:id="@+id/dis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cb4"
app:layout_constraintVertical_bias="0.692" />
</androidx.constraintlayout.widget.ConstraintLayout>
→JAVA
package com.example.feedback;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
RadioButton rb1,rb2,rb3,rb4;
CheckBox cb1,cb2,cb3,cb4;
RadioGroup rg;
Button dis;
String s = "Ratings:-";
String s1="suggestions:- ";
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rb1=findViewById(R.id.rb1);
rb2=findViewById(R.id.rb2);
rb3=findViewById(R.id.rb3);
rb4=findViewById(R.id.rb4);
cb1=findViewById(R.id.cb1);
cb2=findViewById(R.id.cb2);
cb3=findViewById(R.id.cb3);
cb4=findViewById(R.id.cb4);
rg=findViewById(R.id.rg);
dis=findViewById(R.id.dis);
rg.setOnCheckedChangeListener(new
RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
if(rb1.isChecked())
s = s + (rb1.getText().toString() + "\n");
if (rb2.isChecked())
s = s+(rb2.getText().toString()+ "\n");
if (rb3.isChecked())
s = s+(rb3.getText().toString()+ "\n");
if (rb4.isChecked())
s=s+(rb4.getText().toString()+ "\n");
}
});
dis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (cb1.isChecked())
s1=s1+(cb1.getText().toString()+ "\n");
if(cb2.isChecked())
s1=s1+(cb2.getText().toString()+ "\n");
if(cb3.isChecked())
s1=s1+(cb3.getText().toString()+ "\n");
if(cb4.isChecked())
s1=s1+(cb4.getText().toString()+ "\n");
String s2=s+s1;
Toast.makeText(MainActivity.this, s2, Toast.LENGTH_SHORT).show();
}
});
}
}
→Output:-
<TextView
android:id="@+id/textView2"
android:layout_width="358dp"
android:layout_height="42dp"
android:text="patient registration form"
android:textColor="#000000"
android:textSize="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.49"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.005" />
<TextView
android:id="@+id/textView3"
android:layout_width="145dp"
android:layout_height="28dp"
android:layout_marginBottom="548dp"
android:text="Patient Name :-"
android:textColor="#000000"
android:textSize="20dp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.056"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.164" />
<EditText
android:id="@+id/name"
android:layout_width="229dp"
android:layout_height="48dp"
android:layout_marginBottom="548dp"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.13"
app:layout_constraintStart_toEndOf="@+id/textView3"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.098"
tools:ignore="SpeakableTextPresentCheck,SpeakableTextPresentCheck,TouchT
argetSizeCheck" />
<TextView
android:id="@+id/textView5"
android:layout_width="46dp"
android:layout_height="29dp"
android:text="Age:-"
android:textColor="#060606"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.071"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3"
app:layout_constraintVertical_bias="0.065" />
<TextView
android:id="@+id/textView7"
android:layout_width="70dp"
android:layout_height="37dp"
android:layout_marginTop="96dp"
android:text="Gender:-"
android:textColor="#000000"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.068"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:layout_constraintVertical_bias="0.0" />
<EditText
android:id="@+id/age"
android:layout_width="72dp"
android:layout_height="45dp"
android:layout_marginBottom="568dp"
android:ems="10"
android:inputType="number"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.303"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3"
app:layout_constraintVertical_bias="0.888"
tools:ignore="TouchTargetSizeCheck,TouchTargetSizeCheck,SpeakableTextPres
entCheck,SpeakableTextPresentCheck" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Phone :-"
android:textColor="#000000"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.038"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView7"
app:layout_constraintVertical_bias="0.28" />
<EditText
android:id="@+id/pn"
android:layout_width="237dp"
android:layout_height="49dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="72dp"
android:ems="10"
android:inputType="phone"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.209"
app:layout_constraintStart_toEndOf="@+id/textView8"
app:layout_constraintTop_toBottomOf="@+id/rg2"
app:layout_constraintVertical_bias="0.016"
tools:ignore="SpeakableTextPresentCheck,SpeakableTextPresentCheck"
/>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="516dp"
android:text="Marital Status:-"
android:textColor="#000000"
android:textSize="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.058"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView5"
app:layout_constraintVertical_bias="1.0" />
<RadioGroup
android:id="@+id/rg1"
android:layout_width="117dp"
android:layout_height="97dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.116"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.238">
<RadioButton
android:id="@+id/rb1"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:checked="false"
android:text="married"
android:textSize="20dp"
tools:ignore="TouchTargetSizeCheck,TouchTargetSizeCheck,TouchTargetSizeC
heck" />
<RadioButton
android:id="@+id/rb2"
android:layout_width="97dp"
android:layout_height="32dp"
android:checked="false"
android:text="other"
android:textSize="20dp"
tools:ignore="TouchTargetSizeCheck,TouchTargetSizeCheck,TouchTargetSizeC
heck" />
<RadioButton
android:id="@+id/rb3"
android:layout_width="102dp"
android:layout_height="31dp"
android:checked="false"
android:text="single"
android:textSize="20dp"
tools:ignore="TouchTargetSizeCheck,TouchTargetSizeCheck" />
</RadioGroup>
<RadioGroup
android:id="@+id/rg2"
android:layout_width="95dp"
android:layout_height="63dp"
android:layout_marginBottom="368dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.112"
app:layout_constraintStart_toEndOf="@+id/textView7"
app:layout_constraintTop_toBottomOf="@+id/rg1"
app:layout_constraintVertical_bias="0.941">
<RadioButton
android:id="@+id/rb5"
android:layout_width="match_parent"
android:layout_height="29dp"
android:checked="false"
android:text="Female"
android:textSize="20dp"
tools:ignore="TouchTargetSizeCheck,TouchTargetSizeCheck,TouchTargetSizeC
heck,TouchTargetSizeCheck" />
<RadioButton
android:id="@+id/rb4"
android:layout_width="wrap_content"
android:layout_height="33dp"
android:checked="false"
android:text="Male"
android:textSize="20dp"
tools:ignore="TouchTargetSizeCheck,TouchTargetSizeCheck" />
</RadioGroup>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="display"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.512"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pn"
app:layout_constraintVertical_bias="0.673" />
</androidx.constraintlayout.widget.ConstraintLayout>
→JAVA
package com.example.patient;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
rg1.setOnCheckedChangeListener(new
RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
if(rb1.isChecked())
m = m +(rb1.getText().toString()+"\n");
if(rb2.isChecked())
m = m +(rb2.getText().toString()+"\n");
if(rb3.isChecked())
m = m +(rb3.getText().toString()+"\n");
}
});
rg2.setOnCheckedChangeListener(new
RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
if(rb4.isChecked())
g = g +(rb4.getText().toString()+"\n");
if (rb5.isChecked())
g = g +(rb5.getText().toString()+"\n");
}
});
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String n=name.getText().toString();
String a=age.getText().toString();
String p=pn.getText().toString();
String gm=m+g;
Toast.makeText(MainActivity.this, n+"\n"+a+"\n"+gm+"\n"+p,
Toast.LENGTH_SHORT).show();
}
});
}
}
→Output
3.Color change
→xml
<?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:id="@+id/l1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="215dp"
android:layout_height="50dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="121dp"
android:layout_marginRight="121dp"
android:layout_marginBottom="594dp"
android:text="Select any Color"
android:textColor="@color/black"
android:textSize="25dp"
android:textStyle="bold " />
<RadioGroup
android:id="@+id/rg"
android:layout_width="318dp"
android:layout_height="344dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="39dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="176dp"
android:layout_marginEnd="54dp"
android:layout_marginRight="54dp"
android:layout_marginBottom="211dp"
android:gravity="center">
<RadioButton
android:id="@+id/red"
android:layout_width="131dp"
android:layout_height="65dp"
android:background="@color/white"
android:text="Red"
android:textSize="25dp"
android:textStyle="italic|bold" />
<RadioButton
android:id="@+id/blue"
android:layout_width="131dp"
android:layout_height="62dp"
android:background="@color/white"
android:text="Blue"
android:textSize="25dp"
android:textStyle="italic|bold" />
<RadioButton
android:id="@+id/green"
android:layout_width="137dp"
android:layout_height="58dp"
android:background="@color/white"
android:text="Green"
android:textSize="25dp"
android:textStyle="italic|bold" />
<RadioButton
android:id="@+id/pink"
android:layout_width="137dp"
android:layout_height="58dp"
android:background="@color/white"
android:text="Pink"
android:textSize="25dp"
android:textStyle="italic|bold" />
</RadioGroup>
</RelativeLayout>
→JAVA
package com.example.colorchange;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rg=findViewById(R.id.rg);
red=findViewById(R.id.red);
blue=findViewById(R.id.blue);
green=findViewById(R.id.green);
pink=findViewById(R.id.pink);
l1=findViewById(R.id.l1);
rg.setOnCheckedChangeListener(new
RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup, int i) {
switch(i)
{
case R.id.red:
l1.setBackgroundColor(getResources().getColor(R.color.Red));
break;
case R.id.blue:
l1.setBackgroundColor(getResources().getColor(R.color.Blue));
break;
case R.id.green:
l1.setBackgroundColor(getResources().getColor(R.color.Green));
break;
case R.id.pink:
l1.setBackgroundColor(getResources().getColor(R.color.Pink));
break;
}
}
});
}
}
→color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="Red">#FF0000</color>
<color name="Blue">#0000FF</color>
<color name="Green">#008000</color>
<color name="Pink">#FFB6C1</color>
</resources>
→Output
4. Student Registratio
→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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="77dp"
android:layout_height="29dp"
android:text="Name"
android:textColor="#5B09ED"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.062"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.212" />
<EditText
android:id="@+id/e1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="132dp"
android:ems="10"
android:hint="Enter Student Name"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.796"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="TouchTargetSizeCheck" />
<Spinner
android:id="@+id/s1"
android:layout_width="226dp"
android:layout_height="43dp"
android:hint="Select Country"
android:text="select Blood Group"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.972"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.412"
tools:ignore="TouchTargetSizeCheck,SpeakableTextPresentCheck" />
<TextView
android:id="@+id/textView2"
android:layout_width="139dp"
android:layout_height="42dp"
android:text="Blood Group"
android:textColor="#5B09ED"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.077"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.413" />
<AutoCompleteTextView
android:id="@+id/actv"
android:layout_width="160dp"
android:layout_height="49dp"
android:hint="Select Country"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.749"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.629" />
<TextView
android:id="@+id/textView3"
android:layout_width="116dp"
android:layout_height="36dp"
android:text="Country"
android:textColor="#5B09ED"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.071"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.617" />
<Button
android:id="@+id/b1"
android:layout_width="127dp"
android:layout_height="59dp"
android:backgroundTint="#1594F8"
android:text="Save"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.154"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.855" />
<Button
android:id="@+id/b2"
android:layout_width="127dp"
android:layout_height="59dp"
android:text="Exit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.728"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.855" />
<TextView
android:id="@+id/textView4"
android:layout_width="369dp"
android:layout_height="52dp"
android:text="Student Registration"
android:textAlignment="center"
android:textColor="#5B09ED"
android:textSize="34sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.042"
android:gravity="center_horizontal" />
</androidx.constraintlayout.widget.ConstraintLayout>
→java
package com.example.student;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;
import com.example.student.R;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sp = findViewById(R.id.s1);
actv = findViewById(R.id.actv);
b1 = findViewById(R.id.b1);
b2 = findViewById(R.id.b2);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder adb1 = new AlertDialog.Builder(MainActivity.this);
adb1.setTitle("Confirm Save");
adb1.setMessage("Are you sure you want to save?");
adb1.setCancelable(false);
adb1.setNegativeButton("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MainActivity.super.onBackPressed();
Toast.makeText(MainActivity.this, "You clicked over yes",
Toast.LENGTH_SHORT).show();
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder adb2 = new AlertDialog.Builder(MainActivity.this);
adb2.setTitle("Confirm Exit");
adb2.setMessage("Are you sure you want to exit?");
adb2.setCancelable(false);
adb2.setNegativeButton("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MainActivity.super.onBackPressed();
Toast.makeText(MainActivity.this, "You clicked over yes",
Toast.LENGTH_SHORT).show();
}
});
5.friend
→xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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">
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
→hiral.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/hiral">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imageView"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="132dp"
android:layout_marginRight="132dp"
android:layout_marginBottom="529dp"
android:src="@drawable/hiral" />
<RelativeLayout
android:layout_width="391dp"
android:layout_height="116dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="407dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="70dp"
android:orientation="vertical">
</LinearLayout>
<TextView
android:id="@+id/name"
android:layout_width="157dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="118dp"
android:layout_marginRight="118dp"
android:text="Hiral Limbachiya"
android:textColor="@color/black"
android:textSize="17dp" />
<TextView
android:id="@+id/city"
android:layout_width="154dp"
android:layout_height="34dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="123dp"
android:layout_marginRight="148dp"
android:layout_marginBottom="42dp"
android:text="surat"
android:textColor="@color/black"
android:textSize="17dp" />
</RelativeLayout>
</RelativeLayout>
→nikita.xml
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imageView"
android:layout_width="134dp"
android:layout_height="144dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="123dp"
android:layout_marginRight="123dp"
android:layout_marginBottom="530dp"
android:src="@drawable/nikita" />
<RelativeLayout
android:layout_width="391dp"
android:layout_height="116dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="407dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="70dp"
android:orientation="vertical">
</LinearLayout>
<TextView
android:id="@+id/name"
android:layout_width="157dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="118dp"
android:layout_marginRight="118dp"
android:text="Nikita Vsava"
android:textColor="@color/black"
android:textSize="17dp" />
<TextView
android:id="@+id/city"
android:layout_width="154dp"
android:layout_height="34dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="123dp"
android:layout_marginRight="148dp"
android:layout_marginBottom="42dp"
android:text="broda"
android:textColor="@color/black"
android:textSize="17dp" />
</RelativeLayout>
</RelativeLayout>
→khusi.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/khusi">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imageView"
android:layout_width="172dp"
android:layout_height="165dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="117dp"
android:layout_marginRight="117dp"
android:layout_marginBottom="529dp"
android:src="@drawable/khusi" />
<RelativeLayout
android:layout_width="391dp"
android:layout_height="116dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="407dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="70dp"
android:orientation="vertical">
</LinearLayout>
<TextView
android:id="@+id/name"
android:layout_width="157dp"
android:layout_height="35dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="232dp"
android:layout_marginRight="232dp"
android:background="#FFFFFF"
android:text="Khusi Vsava"
android:textColor="@color/black"
android:textSize="17dp" />
<TextView
android:id="@+id/city"
android:layout_width="154dp"
android:layout_height="34dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="234dp"
android:layout_marginRight="148dp"
android:layout_marginBottom="46dp"
android:background="#FCFCFC"
android:text="bhruch"
android:textColor="@color/black"
android:textSize="17dp" />
</RelativeLayout>
</RelativeLayout>
→friend_list.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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">
<RelativeLayout
android:id="@+id/hiral1"
android:layout_width="match_parent"
android:layout_height="99dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imageView"
android:layout_width="95dp"
android:layout_height="match_parent"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:scaleType="centerCrop"
android:src="@drawable/hiral"
tools:ignore="MissingClass" />
<RelativeLayout
android:layout_width="287dp"
android:layout_height="80dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="20dp"
android:layout_marginEnd="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="19dp"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hiral Limbachiya"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/message"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="24dp"
android:text="Hi,How are You"
android:textSize="15dp"
tools:ignore="TextSizeCheck" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/nikita1"
android:layout_width="match_parent"
android:layout_height="99dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="532dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imageView"
android:layout_width="95dp"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/nikita"
tools:ignore="MissingClass" />
<RelativeLayout
android:layout_width="287dp"
android:layout_height="80dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="20dp"
android:layout_marginEnd="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="19dp"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Nikita Vsava"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/message"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="11dp"
android:text="Good Morning niku"
android:textSize="15dp"
tools:ignore="TextSizeCheck" />
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/khusi1"
android:layout_width="match_parent"
android:layout_height="99dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="431dp">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/imageView"
android:layout_width="95dp"
android:layout_height="match_parent"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:scaleType="centerCrop"
android:src="@drawable/khusi"
tools:ignore="MissingClass" />
<RelativeLayout
android:layout_width="287dp"
android:layout_height="80dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="20dp"
android:layout_marginEnd="7dp"
android:layout_marginRight="7dp"
android:layout_marginBottom="19dp"
android:orientation="vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Khusi Vsava"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/message"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="11dp"
android:text="Good Morning Khusi"
android:textSize="15dp"
tools:ignore="TextSizeCheck" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
---------------------------------- Ass-2-------------------------
1.Age find
→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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B9E9EF"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="293dp"
android:layout_height="45dp"
android:text="Select Birth Year"
android:textColor="#171616"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.254"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.11" />
<TextView
android:id="@+id/textView2"
android:layout_width="282dp"
android:layout_height="44dp"
android:text="Age Calculator"
android:textColor="#171616"
android:textSize="34sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.565"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.023" />
<DatePicker
android:id="@+id/dtp"
android:layout_width="359dp"
android:layout_height="392dp"
android:dayOfWeekBackground="#2F99ED"
android:spinnersShown="true"
android:calendarViewShown="false"
android:headerBackground="#2F99ED"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.609"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.446">
</DatePicker>
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Calculate"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.976" />
<TextView
android:id="@+id/t1"
android:layout_width="350dp"
android:layout_height="59dp"
android:textColor="#100F0F"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.672"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.834" />
</androidx.constraintlayout.widget.ConstraintLayout>
→JAVA
package com.example.age;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
import com.example.age.R;
import java.util.Calendar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
t1=(TextView)findViewById(R.id.t1);
b1=(Button)findViewById(R.id.b1);
dtp=(DatePicker)findViewById(R.id.dtp);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int userDOB= +dtp.getYear();
int year=Calendar.getInstance().get((Calendar.YEAR));
int myAge= year-userDOB;
t1.setText("Your age is "+myAge+" years");
}
});
}
}
→output