To define a reference to three components
EditText name = (EditText) Findviewbyid (r.id.name);
EditText passwd = (EditText) Findviewbyid (R.ID.PASSWD);
RadioButton male = (RadioButton) Findviewbyid (R.id.male);
String gender = male.ischecked ()? "Male": "Female";
Person p = new Person (Name.gettext (). toString (), passwd
. GetText (). toString (), gender);
/***********id.gettext () This method gets the contents of the corresponding input box
Data.putserializable ("Person", p);
person is the key for serializable packets only as a token to differentiate between packets being routed. The
P is the transferred object. The
uses intent to send related packets, and a new intent connection is required. The
uses intent's Putextras (data) to send packets.
*******************/
//Create a Bundle object
Bundle data = new bundle ();
Data.putserializable ("Person", p);
//Create a Intent
Intent Intent = new Intent (mainactivity.this,
Resultactivity.class);
Intent.putextras (data);
//Start intent corresponding activity
startactivity (intent);
/**************************************************************
to send packet-related code. The following write accepts the packet and displays the data
***************************************************************/
Define three display text components
TextView name = (TextView) Findviewbyid (r.id.name);
TextView passwd = (TextView) Findviewbyid (R.ID.PASSWD);
TextView gender = (TextView) Findviewbyid (R.id.gender);
The intent of the activity is created to connect to the data received from the previous activity
Intent Intent = Getintent ();
Using packets received by intent, assigned to new objects
Person P = (person) intent.getserializableextra ("person");
/******id.settext method settings display the data sent over the content *********************/
Name.settext ("Your user name is:" + p.getname ());
Passwd.settext ("Your password is:" + p.getpasswd ());
Gender.settext ("Your gender is:" + p.getgender ());
/************ The following is the declaration of the object class method ********************************/
Import java.io.Serializable;
public class person implements serializable{
Private Integer ID;
private String name;
Private String passwd;
Private String gender;
Public person (string name, string passwd, string gender) {
THIS.name = name;
THIS.PASSWD = passwd;
This.gender = gender;
}
/*************** below omit most of the related class methods, GetName (); SetName (); Getgender (); Setgender (); **********************************8/
About Bundle Delivery Messages