[]intent Transfer Object

Source: Internet
Author: User

---restore content starts---

Activity passes values between intent, supports basic data types and string objects and their array objects byte, byte[], Char, char[], Boolean, boolean[], short, short[], int, int [], Long, long[], float, float[], double, double[], String, string[], and the class object that implements the serializable and Parcelable interfaces.

The pass-through class object has never understood how to do it before, and it is all static references. Now finally understand, realize serializable interface, nonsense less say, look at the code.

 Public classCustomeclassImplementsserializable{Private Static Final LongSerialversionuid = -7060210544600464481l; PrivateString name; PrivateString ID; Private intAge ; PrivateString sex;  PublicString GetName () {returnname; }        Public voidsetName (String name) { This. Name =name; }        PublicString getId () {returnID; }        Public voidsetId (String id) { This. ID =ID; }        Public intGetage () {returnAge ; }        Public voidSetage (intAge ) {            This. Age =Age ; }        PublicString Getsex () {returnsex; }        Public voidsetsex (String sex) { This. Sex =sex; }     }
Send part Customeclass cc=NewCustomeclass (); Cc.setage (21st); Cc.setid ("123456"); Cc.setname ("Mingkg21"); Cc.setsex (Male); Intent Intent=NewIntent ( This, PersonInfo.class); Intent.putextra ("Person_info", CC); StartActivity (Intent);
Receiving part Intent Intent=getintent (); Customeclass cc= Customeclass) Intent.getserializableextra ("Person_info"); Settextview (R.id.id, Cc.getid ()); Settextview (R.id.name, Cc.getname ()); Settextview (R.id.sex, Cc.getsex ()); Settextview (R.id.age, String.valueof (Cc.getage ()));

[]intent Transfer Object

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.