how to passing list<> in bundle

后端 未结 2 994
借酒劲吻你
借酒劲吻你 2020-12-18 02:05

I have the following code:

List list = new ArrayList();    
list = setList();    
Intent intent = new Intent(NOTIFI         


        
相关标签:
2条回答
  • 2020-12-18 02:43

    You will need to have ValueActivity implement Parcelable interface and you will need to implement writeToParcel() the CREATOR and a suitable constructor that takes a Parcel as argument. See the documentation of Parcelable interface.

    To put the list into the Bundle, use:

    bundle.putParcelableArrayList("list", list);
    

    To get the list out of the Bundle in the target activity, use:

    List<ValueActivity> = listbundle.getParcelableArrayList("list");
    
    0 讨论(0)
  • 2020-12-18 02:58

    try to use :

    String jsonList = gson.toJson(youList);
    // Add String to bundle
    
    0 讨论(0)
提交回复
热议问题