title: Press Enter to change EditText
body: <p>My problem is that I have a login screen that contains 2 EditText views. When I enter the username and click Enter, it adds more lines, but I want it to change to the EditText password instead. Can someone please help me?</p>
  
  <pre><code> public void onClick(View v){
  
      final TextView user = (TextView)findViewById(R.id.tnome);
      final TextView pw = (TextView)findViewById(R.id.tpw);
      if (user.getText().toString().equals("") || pw.getText().toString().equals((""))) {
          Toast.makeText(MainActivity.this, "Têm de Preencher todos os Campos", Toast.LENGTH_SHORT).show();
          user.requestFocus();
  
      }else{
          if (user.getText().toString().endsWith(" ")){
              user.setText(user.getText().toString().substring(0,user.length()-1));
          }
          user.setText(user.getText().toString().toLowerCase());
          if (user.getText().toString().equals("admin") &amp;&amp; pw.getText().toString().equals("admin")){
  
              startActivity(new Intent(MainActivity.this,Home.class));
              user.setText("");
              pw.setText("");
          }
          user.setOnKeyListener(new View.OnKeyListener() {
  
              public boolean onKey(View v, int keyCode, KeyEvent event) {
                  // If the event is a key-down event on the "enter" button
                  if ((event.getAction() == KeyEvent.ACTION_DOWN) &amp;&amp;
                          (keyCode == KeyEvent.KEYCODE_ENTER))
                  {
                      // Perform action on Enter key press
                      user.clearFocus();
                      pw.requestFocus();
                      return true;
                  }
                  return false;
              }
          });
  
          pw.setOnKeyListener(new View.OnKeyListener() {
  
              public boolean onKey(View v, int keyCode, KeyEvent event) {
  
                  if ((event.getAction() == KeyEvent.ACTION_DOWN) &amp;&amp;
                          (keyCode == KeyEvent.KEYCODE_ENTER))
                  {
                      // Perform action on Enter key press
                      // check for username - password correctness here
                      return true;
                  }
                  return false;
              }
          });
      }
  }
  </code></pre>