pr9 - Copy
pr9 - Copy
xmlns:app="http://schemas.andro id.com/apk/res-auto"
xmlns:tools="http://schemas.andr oid.com/tools"
android:layout_width="match_pa rent"
android:layout_height="match_p arent"
tools:context=".MainActivity">
<TextView android:id="@+id/Name"
android:layout_width="wrap_con
Maharashtra State Board of Technical Education 73
tent"
android:layout_height="wrap_co ntent"
android:text="Name"
android:layout_marginTop="40d p"
android:layout_centerHorizontal= "true"
android:textSize="20dp"
/>
<EditText android:id="@+id/Name_ET"
android:layout_width="match_pa rent"
android:layout_height="wrap_co ntent"
android:ems="10"
android:inputType="textPersonN ame"
android:layout_centerHorizontal= "true"
android:layout_below="@+id/Na me_ET"
android:textSize="20dp"
/>
<EditText android:id="@+id/Age_ET"
android:layout_width="match_pa rent"
android:layout_height="wrap_co ntent"
android:ems="10"
android:inputType="textPersonN ame"
android:layout_marginTop="20d p"
android:layout_below="@+id/Age "
android:layout_below="@+id/Na me"
android:layout_marginTop="20d p"
/>
<TextView android:id="@+id/Age"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:text="Age"
android:layout_marginTop="40d p"
/>
<TextView android:id="@+id/Branch"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:text="Branch"
android:layout_marginTop="40d p"
android:layout_centerHorizontal= "true"
android:layout_below="@+id/Age
_ET"
android:textSize="20dp"
/>
<EditText
android:id="@+id/Branch_ET"
android:layout_width="match_pa rent"
android:layout_height="wrap_co ntent"
android:ems="10"
android:inputType="textPersonN ame"
android:layout_marginTop="20d p"
android:layout_below="@+id/Bra nch"
/>
<TextView android:id="@+id/Semester"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:text="Semester"
android:layout_marginTop="40d p"
android:layout_centerHorizontal= "true"
android:layout_below="@+id/Bra nch_ET"
android:textSize="20dp"
/>
<EditText
android:id="@+id/Semester_ET"
android:layout_width="match_pa rent"
android:layout_height="wrap_co ntent"
android:ems="10"
android:inputType="textPersonN ame"
android:layout_marginTop="20d p"
android:layout_below="@+id/Se mester"
/>
<Button android:id="@+id/Login"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co ntent"
android:text="Login"
android:layout_below="@+id/Se mester_ET"
android:layout_marginTop="40d p"
android:layout_centerHorizontal= "true"
/>
<TextView android:id="@+id/Login"
android:layout_width="wrap_con tent"
android:layout_height="wrap_co
ntent"
android:text="Student Login" android:textSize="40dp"
android:layout_centerHorizontal= "true"
android:textColor="@color/teal_2 00"
/>
</RelativeLayout>
Java File:
package com.example.exp10_2;
import android.os.Bundle;
EditText name_et,age_et,branch_et,sem_et
;
String Username,Age,Branch,Semester;
Button login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceStat
e);
setContentView(R.layout.activity_ main);
name_et=findViewById(R.id.Nam e_ET);
age_et=findViewById(R.id.Age_E T);
branch_et=findViewById(R.id.Br anch_ET);
sem_et=findViewById(R.id.Semes ter_ET);
login
=findViewById(R.id.Login);
login.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View
v) {
Username=name_et.getText().toSt ring();
Age=age_et.getText().toString();
Branch=branch_et.getText().toStr ing();
Semester=sem_et.getText().toStrin g();
Toast.makeText(MainActivity.this
,"Welcome "+Username
,Toast.LENGTH_SHORT).show()
;
Toast.makeText(MainActivity.this
,"Age "+Age
,Toast.LENGTH_SHORT).show()
;
Toast.makeText(MainActivity.this
,"Branch "+Branch
,Toast.LENGTH_SHORT).show()
;
Toast.makeText(MainActivity.this
,"Semester "+Semester
,Toast.LENGTH_SHORT).show()
;
Intent intent=new
Intent(MainActivity.this,Empty_A ctivity.class);
// intent.putExtra("username",User name);
startActivity(intent);
}
});
}
}