About Bundle Delivery Messages

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.