How to pass bean class one activity to another activity on android

前端 未结 4 1959
情书的邮戳
情书的邮戳 2021-01-16 11:25

Hi this is my listview onClicklister.

when i click the list item , I pass the the arraylist which is getting from bean class one activity to another activity like

4条回答
  •  深忆病人
    2021-01-16 11:40

    You can pass your object using Parcelable class..

    something like,

    public class RouteBean implements Parcelable {
    
    }
    

    Once you have your objects implement Parcelable it's just a matter of putting them into your Intents with putExtra():

    Intent i = new Intent();
    i.putExtra("object", Parcelable_Object);
    

    Then you can pull them back out with getParcelableExtra():

    Intent i = getIntent();
    RouteBean bean = (RouteBean) i.getParcelableExtra("object");
    

    For more info look at this SO question How to pass an object from one activity to another on Android

提交回复
热议问题