首先在第一个活动的点击事件中创建Intent 并获取要传的值

  button2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(MainActivity.this, "你点击了按钮",
                    Toast.LENGTH_SHORT).show();
            Intent intent1 = new Intent(MainActivity.this,MainActivity2.class);
            EditText login = findViewById(R.id.username);
            EditText reg = findViewById(R.id.password);
            intent1.putExtra("username",login.getText().toString());
            intent1.putExtra("password",reg.getText().toString());
            startActivity(intent1);
        }
    });

然后在第二个活动的点击事件中 通过Intent获取到第一个活动传的值 然后用setText设置在第二个活动的EditText上

         button1.setOnClickListener(new View.OnClickListener() {
        Intent intent = getIntent();
        EditText user = (EditText) findViewById(R.id.username2);
        EditText pass = (EditText) findViewById(R.id.password2);
        String username2 = intent.getStringExtra("username");
        String password2 = intent.getStringExtra("password");
        @Override
        public void onClick(View v) {
            user.setText(username2);
            pass.setText(password2);
    }
    });