二、传递用户信息数据的JAVA代码
package com.example.john.dataget; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; public class MainActivity extends AppCompatActivity { private RadioButton manRadio; private RadioButton womanRadio; private EditText et_password; private Button btn_send; private EditText et_name; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); 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.radioremale); //点击用户信息按钮进行数据传递 btn_send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { passDate(); } }); } //传递数据 public void passDate(){ //创建Intent对象,启动Activity02 Intent intent=new Intent(this,Activity02.class); //将数据存入Intent 对象 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); } }学习了如何利用Intent进行信息数据的传递