Passing object array list between fragments in Android development

前端 未结 4 1550
梦如初夏
梦如初夏 2021-01-14 09:58

I am trying to pass arraylist between fragments in Android development. This is the part where I tried to pass Transaction array list to another fragment:

sw         


        
4条回答
  •  野的像风
    2021-01-14 10:08

    ArrayList transactionList = new ArrayList<>();
    

    pass the transactionList to the bundle

    Bundle bundle = new Bundle();
    bundle.putSerializable("key", transactionList);
    

    and in the receiving fragment

    ArrayList transactionList = (ArrayList)getArguments().getSerializable("key");
    

    NOTE: to pass your bean class via bundle you have to implement serializable i.e

    YourBeanClass implements Serializable

提交回复
热议问题