Passing object array list between fragments in Android development

前端 未结 4 1552
梦如初夏
梦如初夏 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:22

    1.You can either pass it by converting into json as specified by @Bhupat.

    2.Another way is you make your Transaction class parcelable and the use

     b.putParcelableArrayList("list",your_list);
    

    for getting list

    your_list = getArguments().getParcelableArrayList("list");
    

    EDIT you have too sepcigy type token for getting it back

     transactionlist = new Gson().fromJson(str,  new TypeToken>);
    

    In your case new TypeToken>

提交回复
热议问题