How to send objects through bundle

前端 未结 11 1281
我寻月下人不归
我寻月下人不归 2020-11-27 13:15

I need to pass a reference to the class that does the majority of my processing through a bundle.

The problem is it has nothing to do with intents or contexts and ha

11条回答
  •  不知归路
    2020-11-27 13:34

    Possible solution:

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

    Class CustomObject:

    class CustomObject implements Serializable{
     private SubCustomObject1 sc1;
     private SubCustomObject2 sc2;
    }
    

    Subcustom objects:

    class SubCustomObject1 implements Serializable{ }
    
    class SubCustomObject2  implements Serializable{ }
    

提交回复
热议问题