Bundle Transfer Object

Source: Internet
Author: User

Bundledemo.java----The main activity is passed to Activitya.java from this activity

public class Bundledemo extends Activity {@Overrideprotected void onCreate (Bundle savedinstancestate) {//TODO Auto-gener Ated method Stubsuper.oncreate (savedinstancestate); Setcontentview (r.layout.bundle_activity); User user = new user (); Intent Intent = new Intent (this, activitya.class); Bundle bundle = new Bundle (), bundle.putserializable ("user", user), Intent.putextras (bundle), startactivity (intent);}} Class User implements Serializable {public ArrayList getList () {arraylist<string> list = new Arraylist<string> ;(), List.add ("Tian1"), List.add ("Tian2"), List.add ("tian3"); List.add ("Tian4"); return list;}

Activitya.java---Get the user class

public class Activitya extends Activity {private Button button;private String Tag = "yuxlong2010"; int count = 0;    Private TextView TextView;    User user, @Overrideprotected void onCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); LOG.D (Tag, "I ' m  onCreate"); Setcontentview (r.layout.activity_a); TextView = (TextView) Findviewbyid ( R.ID.TEXTVIEW1); button = (button) Findviewbyid (R.id.button1); Bundle bundle = This.getintent (). Getextras (); User  = (user) bundle.get ("user"); Button.setonclicklistener (new View.onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated method Stub//startactivity (new Intent (Activitya.this,activitya.class)); Textview.settext (User.getlist (). Get (0). toString ());});

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