Advertisement
Guest User

hahahaha

a guest
May 2nd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. package com.example.lois69.cafeku;
  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.Toast;
  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.  
  18. final EditText username =(EditText) findViewById(R.id.username);
  19. final EditText password = (EditText) findViewById(R.id.password);
  20. Button login = (Button) findViewById(R.id.Login);
  21. Button aboute = (Button) findViewById(R.id.about) ;
  22.  
  23. aboute.setOnClickListener(new View.OnClickListener() {
  24. @Override
  25. public void onClick(View v) {
  26. Intent move = new Intent(MainActivity.this,About.class);
  27. startActivity(move);
  28.  
  29. }
  30. });
  31.  
  32. login.setOnClickListener(new View.OnClickListener() {
  33. @Override
  34. public void onClick(View v) {
  35.  
  36. String user = username.getText().toString();
  37. String pass = password.getText().toString();
  38.  
  39. if((user.equals("admin"))&&(pass.equals("admin")))
  40.  
  41. {
  42. Intent myIntent = new Intent(MainActivity.this, halaman2.class);
  43. startActivity(myIntent);
  44. }
  45. else
  46.  
  47. {
  48. Toast.makeText(getApplicationContext(), "Username dan password salah", Toast.LENGTH_SHORT).show();
  49. }
  50.  
  51. }
  52. });
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement