Guest User

Untitled

a guest
Oct 21st, 2019
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.vnpt.training_01;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4.  
  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 MainActivity extends AppCompatActivity implements View.OnClickListener {
  13. private EditText editEmail;
  14. private EditText editPass;
  15. private Button btnLogin;
  16. private TextView txtRegisterNow;
  17.  
  18. @Override
  19. protected void onCreate(Bundle savedInstanceState) {
  20. super.onCreate(savedInstanceState);
  21.  
  22. setContentView(R.layout.activity_main);
  23. initView();
  24. }
  25.  
  26. void initView() {
  27. editEmail = findViewById(R.id.editEmail);
  28. editPass = findViewById(R.id.editPassword);
  29. btnLogin = findViewById(R.id.btnLogin);
  30. txtRegisterNow = findViewById(R.id.txtRegisterNow);
  31.  
  32. btnLogin.setOnClickListener(this);
  33. txtRegisterNow.setOnClickListener(this);
  34. }
  35.  
  36. @Override
  37. public void onClick(View v) {
  38. switch (v.getId()) {
  39. case R.id.btnLogin:
  40. handleLoginClicked();
  41. return;
  42.  
  43. case R.id.txtRegisterNow:
  44. handleRegisterClicked();
  45. return;
  46. }
  47. }
  48.  
  49. void handleLoginClicked() {
  50. Toast.makeText(MainActivity.this, "clicked",
  51. Toast.LENGTH_SHORT).show();
  52. }
  53.  
  54. void handleRegisterClicked() {
  55. Toast.makeText(MainActivity.this, " textviewclicked",
  56. Toast.LENGTH_SHORT).show();
  57. }
  58.  
  59. }
RAW Paste Data