#2
SKYYYF2017-02-13 14:21
|
第一个是MainActivity.java,第二个是RegMsg.java
程序代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtUsername = (EditText) findViewById(R.id.txtUsername);
txtPassword = (EditText) findViewById(R.id.txtPassword);
btnLook = (Button)findViewById(R.id.btnLook);
manRadio = (RadioButton)findViewById(R.id.radioMale);
womanRadio = (RadioButton)findViewById(R.id.radioFemale);
txtEmail = (EditText) findViewById(R.id.txtEmail);
btnLook = (Button)findViewById(R.id.btnLook);
btnLook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,RegMsg.class);
Bundle bundle = new Bundle();
bundle.putString("username",txtUsername.getText().toString());
bundle.putString("password",txtPassword.getText().toString());
Log.v("-------------密码为-----------------",txtUsername.getText().toString());
String str="";
if(manRadio.isChecked())
str="男";
else if(womanRadio.isChecked())
str="女";
bundle.putString("sex",str);
bundle.putString("email",txtEmail.getText().toString());
intent.putExtras(bundle);
startActivity(intent);
}
});
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtUsername = (EditText) findViewById(R.id.txtUsername);
txtPassword = (EditText) findViewById(R.id.txtPassword);
btnLook = (Button)findViewById(R.id.btnLook);
manRadio = (RadioButton)findViewById(R.id.radioMale);
womanRadio = (RadioButton)findViewById(R.id.radioFemale);
txtEmail = (EditText) findViewById(R.id.txtEmail);
btnLook = (Button)findViewById(R.id.btnLook);
btnLook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this,RegMsg.class);
Bundle bundle = new Bundle();
bundle.putString("username",txtUsername.getText().toString());
bundle.putString("password",txtPassword.getText().toString());
Log.v("-------------密码为-----------------",txtUsername.getText().toString());
String str="";
if(manRadio.isChecked())
str="男";
else if(womanRadio.isChecked())
str="女";
bundle.putString("sex",str);
bundle.putString("email",txtEmail.getText().toString());
intent.putExtras(bundle);
startActivity(intent);
}
});
}
程序代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent=this.getIntent();
Bundle bundle = intent.getExtras();
String username = bundle.getString("username");
String password = bundle.getString("password");
String sex = bundle.getString("sex");
String email = bundle.getString("email");
TextView viewUser = (TextView) findViewById(R.id.lbl);
viewUser.setText("用户名:"+username+" 密码:"+password+" 性别:"+sex+" 邮件地址:"+email);
Log.v("------------------用户名为--------------",username);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent=this.getIntent();
Bundle bundle = intent.getExtras();
String username = bundle.getString("username");
String password = bundle.getString("password");
String sex = bundle.getString("sex");
String email = bundle.getString("email");
TextView viewUser = (TextView) findViewById(R.id.lbl);
viewUser.setText("用户名:"+username+" 密码:"+password+" 性别:"+sex+" 邮件地址:"+email);
Log.v("------------------用户名为--------------",username);
}