Guest User

Untitled

a guest
Oct 28th, 2017
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. package com.szabist.midterm;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.widget.Button;
  8. import android.widget.EditText;
  9. import android.widget.TextView;
  10.  
  11. public class MainActivity extends AppCompatActivity {
  12.  
  13. @Override
  14. protected void onCreate(Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16. setContentView(R.layout.activity_main);
  17. final Intent intent = new Intent(this,ListScreen.class);
  18. final EditText txtUser = (EditText)findViewById(R.id.txt_username);
  19. final EditText txtPassword = (EditText) findViewById(R.id.txt_password);
  20. Button btn = (Button)findViewById(R.id.btnLogin);
  21. btn.setOnClickListener(new View.OnClickListener() {
  22. @Override
  23. public void onClick(View v) {
  24. if (txtUser.getText().length()>1){
  25. if(txtPassword.getText().length()>1){
  26. startActivity(intent);
  27. }
  28. else{
  29. txtPassword.setError("Please Enter Valid Password");
  30. }
  31. }
  32. else{
  33. txtUser.setError("Please enter a valid username");
  34. }
  35. }
  36. });
  37. }
  38. }
Add Comment
Please, Sign In to add comment