---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