Effect:
If you want to see an example, an article of interest can be seen before
Android Viewpager Fragment Implementation tab
Some key codes:
public class Serializeactivity extends Activity implements Serializable {Button btnlist, btnparcelable, Btnserialze; Private final String TAG = "Serializeactivity";p ublic final static string list_key = "ArrayList";p ublic final static Strin G Par_key = "parcelable";p ublic final static String Ser_key = "serializable";p rivate static final Long Serialversionuid = 1l;private arraylist<string> m_list; @Overrideprotected void OnCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_serialize); Initview (); Initlist ();} /* * Initialize view */public void Initview () {btnlist = (button) Findviewbyid (r.id.btnlist); btnparcelable = (Button) Findviewbyid (R . id.btnparcelable); Btnserialze = (Button) Findviewbyid (R.id.btnserialze); Btnlist.setonclicklistener (Btnlistener); Btnparcelable.setonclicklistener (Btnlistener); Btnserialze.setonclicklistener (Btnlistener);} public void Initlist () {m_list = new arraylist<string> (); M_list.add ("www.88ios.com"); M_list.add ("AndroiD Mobile Development "); M_list.add (" Introduction to iOS development "); /* * button click event */onclicklistener btnlistener = new Onclicklistener () {public void OnClick (View v) {switch (V.getid ()) {case R . Id.btnlist:intentList (); break;case R.id.btnparcelable:intentparcelabe (); Break;case R.id.btnserialze: Intentshowser (); break;}}; /* * */public void Intentlist () {Intent list_intent = new Intent (); List_intent.putstringarraylistextra (List_key, m_ list); List_intent.setclass (Serializeactivity.this, Showinfo.class); startactivity (list_intent);} /* * */public void Intentparcelabe () {Student m_student = new Student (); M_student.setname ("88ios.com"); m_student.se Tage, M_student.setsex ("male"), Intent p_intent = new Intent (serializeactivity.this,showparcelabe.class); Bundle Mbundle = new bundle (); Mbundle.putparcelable (Par_key, m_student);p _intent.putextras (Mbundle); StartActivity (P _intent);} /* * */public void Intentshowser () {final Serializablemap myMap = new Serializablemap (); list<map<string, object>> list = nEW arraylist<map<string, object>> (); Map<string, object> maplist; map<string, object> PARAMMAP4 = new hashmap<string, object> ();p arammap4.put ("name", "Hongsheng Peng");p Arammap4.put ( "Website", "www.88ios.com");p arammap4.put ("Address", "Guangzhou"); Mymap.setmap (PARAMMAP4); Serializablemap Serializablemap = (serializablemap) mymap;maplist = Serializablemap.getmap (); List.add (maplist); I Ntent mintent = new Intent (serializeactivity.this, Showser.class); Bundle Mbundle = new bundle (); Mbundle.putserializable ("Map", (Serializable) myMap); Mbundle.putserializable ("Map", (Serializable) list); Mintent.putextras (Mbundle); startactivity (mintent);}}
Showinfo.java
public class Showinfo extends Activity {private Intent list_intent;private arraylist<string> m_arraylist;private TextView TextView; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_show_info); TextView = (TextView) Findviewbyid (R.id.textview); StringBuffer sb = new StringBuffer (); list_intent = Getintent (); m_arraylist = List_intent.getextras (). Getstringarraylist (Serializeactivity.list_key); m_arraylist.get (0); Sb.append (M_arraylist.get (0) + "\ n" + m_ Arraylist.get (1) + "\ n" + m_arraylist.get (2)); Textview.settext (SB);}}
Showparcelabe.java
public class Showparcelabe extends Activity {private TextView TextView; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.activity_show_parcelabe); TextView = (TextView) Findviewbyid (R.id.textview); Student p_student = (Student) getintent (). Getparcelableextra (Serializeactivity.par_key); Textview.settext ("Name:" + p_student.getname () + "\ n" + "Age:" + p_student.getage () + "\ n" + "Gender:" + P_student.getse X () + "\ n" + "class:" + P_student.getclass ());} }
Showser.java
public class Showser extends Activity {private TextView TextView; StringBuilder sb = new StringBuilder (), @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate ( Savedinstancestate); Setcontentview (r.layout.activity_show_ser); TextView = (TextView) Findviewbyid (R.id.textview) ; Map<string, object> maplist; Bundle bundle = Getintent (). Getextras (); Serializablemap Serializablemap = (serializablemap) bundle.get ("map"); maplist = Serializablemap.getmap ();/*for ( String K:maplist.keyset ()) {Toast.maketext (this, "" + maplist.get (k), Toast.length_short). Show (); */set Set = Maplist.entryset (); Iterator it = Set.iterator (); while (It.hasnext ()) {Map.entry Entry = (map.entry) it.next (); String key = (string) entry.getkey (); String valu = (string) entry.getvalue (); Sb.append (key+ " " +valu+ "\ n");} Textview.settext (SB); }}
Reprint please keep the link
Http://hongshengpeng.com/article/show/271.aspx
Source code Download
Qq
AC Group: 154950206 incoming group verification: 88ios