Passing object array list between fragments in Android development

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

    add this gradle in your build.gradle compile 'com.google.code.gson:gson:2.7'

    String str = new Gson().toJson(arrayList);
    bundle.putStrin("str",str);
    

    and destination fragemnt

    String str = bundle.getString("str");
    
    arrayList = new Gson().fromJson(str,ArrayList.class);
    

提交回复
热议问题