Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. package com.example.martin.helha_base;
  2.  
  3. import android.content.Intent;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.os.Bundle;
  6. import android.util.Log;
  7. import android.view.View;
  8. import android.widget.Button;
  9. import android.widget.EditText;
  10. import android.widget.TextView;
  11.  
  12. import org.w3c.dom.Text;
  13.  
  14. public class MainActivity extends AppCompatActivity {
  15. private TextView tvExample, tvUsername, tvPassword;
  16.  
  17. private Button btnExample,btnSignin, btnReset;
  18. private EditText etUsername, etPassword;
  19. @Override
  20. protected void onCreate(Bundle savedInstanceState) {
  21. super.onCreate(savedInstanceState);
  22. setContentView(R.layout.activity_main);
  23.  
  24. this.tvExample = (TextView)findViewById(R.id.tv_main_example);
  25.  
  26. this.tvExample.setText("Hello world");
  27.  
  28. this.btnExample = (Button)findViewById(R.id.btn_main_exemple);
  29. this.btnExample.setOnClickListener(new View.OnClickListener() {
  30. @Override
  31. public void onClick(View v) {
  32. startActivity(new Intent(MainActivity.this,Main2Activity.class));
  33. }
  34. });
  35.  
  36. this.etUsername = (EditText)findViewById(R.id.et_username);
  37. this.etPassword = (EditText)findViewById(R.id.et_password);
  38.  
  39. this.btnSignin = (Button)findViewById(R.id.btn_signin);
  40. this.btnReset = (Button)findViewById(R.id.btn_signreset);
  41.  
  42. this.btnSignin.setOnClickListener(new View.OnClickListener() {
  43. @Override
  44. public void onClick(View v) {
  45. signInAction();
  46. }
  47. });
  48.  
  49. this.btnReset.setOnClickListener(new View.OnClickListener() {
  50. @Override
  51. public void onClick(View v) {
  52. resetAction();
  53. }
  54. });
  55. }
  56. private void resetAction() {
  57. this.etUsername.setText("");
  58. this.etPassword.setText("");
  59. }
  60.  
  61. private void signInAction() {
  62. String username = this.etUsername.getText().toString();
  63. String password = this.etPassword.getText().toString();
  64.  
  65. Log.d("Connexion",String.format("%s - %s",username, password));
  66.  
  67. }
  68.  
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement