Mad 28
Mad 28
Create a login application where you will have to validate username and password till the username
and password Is not validated,login button remain disabled.
Activity_main.xml
1|Page
Subject: MAD[22617] Practical no: 28
Performed by: Pratik Bais Roll no: 51
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/etPassword"
android:layout_centerHorizontal="true"
android:layout_marginTop="38dp"
android:text="LOGIN"
/>
<TextView
android:id="@+id/tvLoginStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button"
android:layout_centerHorizontal="true"
android:layout_marginTop="100sp"
/>
</RelativeLayout>
MainActivity.java
package com.example.practicalno28;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
EditText etUsername, etPassword;
Button btnStatus;
TextView tvLoginStatus;
@Override
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etUsername = (EditText) findViewById(R.id.etUsername);
etPassword = (EditText) findViewById(R.id.etPassword);
btnStatus = (Button) findViewById(R.id.button);
tvLoginStatus = (TextView) findViewById(R.id.tvLoginStatus);
etPassword.addTextChangedListener(TextChange);
etUsername.addTextChangedListener(TextChange);
check();
}
private TextWatcher TextChange=new TextWatcher() {
@Override
2|Page
Subject: MAD[22617] Practical no: 28
Performed by: Pratik Bais Roll no: 51
Output:
3|Page