Advertisement
Guest User

Untitled

a guest
Nov 27th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. package com.example.test.pertemuan8;
  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. import android.widget.Toast;
  11.  
  12. public class LoginActivity extends AppCompatActivity {
  13.  
  14. @Override
  15. protected void onCreate(Bundle savedInstanceState) {
  16. super.onCreate(savedInstanceState);
  17. setContentView(R.layout.activity_login);
  18.  
  19. //ambil data yg di passing
  20. Intent i = getIntent();
  21. final String register_username = i.getStringExtra("Username");
  22. final String register_password = i.getStringExtra("Password");
  23.  
  24.  
  25. final EditText username = findViewById(R.id.login_username);
  26. final EditText password = findViewById(R.id.login_password);
  27. Button button = findViewById(R.id.login_button);
  28. TextView click = findViewById(R.id.login_clickhere);
  29.  
  30. click.setOnClickListener(new View.OnClickListener() {
  31. @Override
  32. public void onClick(View v) {
  33. Intent intent = new Intent(LoginActivity.this,RegisterActivity.class);
  34. startActivity(intent);
  35. }
  36. });
  37.  
  38. button.setOnClickListener(new View.OnClickListener() {
  39. @Override
  40. public void onClick(View v) {
  41. if(!username.getText().toString().equals(register_username)){
  42. Toast.makeText(LoginActivity.this, "Username Invalid", Toast.LENGTH_SHORT).show();
  43. }else if(!password.getText().toString().equals(register_password)){
  44. Toast.makeText(LoginActivity.this, "Password Invalid", Toast.LENGTH_SHORT).show();
  45. }else {
  46. Toast.makeText(LoginActivity.this, "Login Success", Toast.LENGTH_SHORT).show();
  47. }
  48. }
  49. });
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement