Prog TextView EditTextView
Prog TextView EditTextView
Prog TextView EditTextView
xml
MainActivity.java
package in.edu.vpt.texteditdemo;
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);
uname=(EditText)findViewById(R.id.uname);
upass=(EditText)findViewById(R.id.upass);
submit=(Button)findViewById(R.id.submitBtn);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(uname.getText().toString().equals(defname) &&
upass.getText().toString().equals(defpass)){
Toast.makeText(MainActivity.this,"Login
Successful",Toast.LENGTH_LONG).show();
}
else{
Toast.makeText(MainActivity.this,"Login
Unsuccessful, invalid credentials",Toast.LENGTH_SHORT).show();
}
}
});
}
}
Output