parent
9d82ceeb80
commit
8424e0e234
@ -0,0 +1,60 @@
|
||||
package com.example.register;
|
||||
|
||||
public class User {
|
||||
private String username;
|
||||
private String password;
|
||||
private String sex;
|
||||
private String address;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public User(String phone, String password, String sex, String address) {
|
||||
this.username = phone;
|
||||
this.password = password;
|
||||
this.sex = sex;
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.username = phone;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"phone='" + username + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", sex='" + sex + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.example.register;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class user extends AppCompatActivity{
|
||||
EditText username;
|
||||
|
||||
Button exit;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.user);
|
||||
//username = findViewById(R.id.login_name);
|
||||
exit=findViewById(R.id.exit);
|
||||
exit.setOnClickListener(view -> {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(this, loginActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
|
||||
setContentView(R.layout.user);
|
||||
//接收结果
|
||||
Intent intent =this.getIntent();
|
||||
String ss1=intent.getStringExtra("username");
|
||||
//String ss2=intent.getStringExtra("password1");
|
||||
|
||||
}
|
||||
}*/
|
@ -0,0 +1,54 @@
|
||||
package com.example.register;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.content.Intent;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class userActivity extends AppCompatActivity{
|
||||
EditText username,sex,city;
|
||||
|
||||
Button exit;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.user);
|
||||
init();
|
||||
params();
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化组件
|
||||
*/
|
||||
public void init(){
|
||||
username = findViewById(R.id.login_name);
|
||||
sex = findViewById(R.id.reg_sex);
|
||||
city = findViewById(R.id.reg_address);
|
||||
|
||||
exit=findViewById(R.id.exit);
|
||||
exit.setOnClickListener(view -> {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(this, loginActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收参数
|
||||
*/
|
||||
|
||||
public void params(){
|
||||
//接收结果
|
||||
Bundle bundle = this.getIntent().getExtras();
|
||||
String usernameStr =bundle.getString("username");
|
||||
String passwordStr =bundle.getString("password");
|
||||
String sexStr =bundle.getString("sex");
|
||||
String cityStr =bundle.getString("city");
|
||||
username.setText("用户名: " + usernameStr);
|
||||
sex.setText("性别: " + sexStr);
|
||||
city.setText("地址: " + cityStr);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue