protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_three);
et_name=(EditText)findViewById(R.id.et_name);
et_password=(EditText)findViewById(R.id.et_password);
btn_send=(Button)findViewById(R.id.btn_send);
manRadio=(RadioButton)findViewById(R.id.radioMale);
womanRadio=(RadioButton)findViewById(R.id.radioFemale);
// btn_send=(Button)findViewById(R.id.btn_send);
//点击提交用户信息的按钮进行数据传递
btn_send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
passDate();
}
});
}
//传递数据
public void passDate(){
//创建Intent对象
Intent intent= new Intent(this,FourActivity.class);
intent.putExtra("name",et_name.getText().toString().trim());
intent.putExtra("password",et_password.getText().toString().trim());
String str="";
if(manRadio.isChecked()){
str="男";
}else if(womanRadio.isChecked()){
str="女";
}
intent.putExtra("sex",str);
startActivity(intent);
ThreeActivity.this.finish();
}
需要在清单文件中备注
<activity android:name=".FourActivity"
android:label="@string/app_name">
</activity>