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

前端 未结 4 1933
情书的邮戳
情书的邮戳 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:37

    I think it is possible. You have to send the Object of your class like this,

       intent.putExtra("RouteBean", bean); 
    

    And retrieve it like this in your next activity,

    getIntent().getSerializableExtra("RouteBean");
    

    But your class has to implement Serializable Interface.

    Or you can use Parcelable Interface,

    Here is a Example,

    https://stackoverflow.com/a/6923794/603744

    For the first method, your class should be like this,

    public class RouteBean implements Serializable 
    {
    
    }
    

    And for the next one,

    public class RouteBean implements Parcelable 
    {
    
    }
    

提交回复
热议问题