Write A Program To Accept Username and Password From The End User Text View and Edit Text
Write A Program To Accept Username and Password From The End User Text View and Edit Text
1905300038
Practical No: 07
Exercise
1. Write a program to accept username and password from the end user Text
View and edit Text
Activity_Main.xml:
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="130dp"
android:layout_x="214dp"
android:layout_y="431dp"
android:text="LOG IN"
android:textSize="34dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.815"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.89" />
<EditText
android:id="@+id/editTextTextusername"
android:layout_width="277dp"
android:layout_height="130dp"
android:layout_marginTop="100dp"
android:layout_x="24dp"
android:layout_y="86dp"
android:ems="10"
android:hint="user_name"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Pingle Sakshi
1905300038
<EditText
android:id="@+id/editTextNumberPassword"
android:layout_width="278dp"
android:layout_height="100dp"
android:layout_marginTop="56dp"
android:layout_x="27dp"
android:layout_y="258dp"
android:ems="10"
android:hint="password"
android:inputType="numberPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextusername" />
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java:
package com.example.practical7question1excercise;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
username=(EditText) findViewById(R.id.editTextTextusername);
Password=(EditText) findViewById(R.id.editTextNumberPassword);
LOGIN=(Button) findViewById(R.id.button);
LOGIN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText( MainActivity.this, "login succesfully", Toast.LENGTH_SHORT).show();
Pingle Sakshi
1905300038
}
});
}
}
Pingle Sakshi
1905300038
<TextView
android:id="@+id/Textview"
android:layout_width="304dp"
android:layout_height="181dp"
android:layout_marginBottom="20dp"
android:text="personal information of students"
android:textSize="25dp"
android:textStyle="italic"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.242"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
<EditText
android:id="@+id/name"
android:layout_width="347dp"
android:layout_height="92dp"
android:layout_marginBottom="20dp"
android:ems="10"
android:hint="Enter you name"
android:inputType="textPersonName"
android:textSize="18sp"
android:gravity="start"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.474"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.119" />
Pingle Sakshi
1905300038
<EditText
android:id="@+id/dob"
android:layout_width="349dp"
android:layout_height="86dp"
android:ems="10"
android:gravity="start"
android:hint="Enter your date of birth"
android:inputType="textPersonName"
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.293" />
<EditText
android:id="@+id/contactno"
android:layout_width="345dp"
android:layout_height="87dp"
android:ems="10"
android:gravity="start"
android:hint="Enter your contact no"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.53"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.456" />
<Button
android:id="@+id/btnSubmit"
android:layout_width="180dp"
android:layout_height="59dp"
android:text="Submit"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.93"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.617" />
</androidx.constraintlayout.widget.ConstraintLayout>
Pingle Sakshi
1905300038
MainActivity.java:
package com.example.practical7question2;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;