Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何为未实现Parcelable的对象的Arraylist实现Parcelable?_Java_Android_Parcelable - Fatal编程技术网

Java 如何为未实现Parcelable的对象的Arraylist实现Parcelable?

Java 如何为未实现Parcelable的对象的Arraylist实现Parcelable?,java,android,parcelable,Java,Android,Parcelable,我有一个Jar文件中的类,它没有实现parcelable,我无法编辑Jar文件。我从服务器获取对象作为响应,需要使用parcelable将其传递给下一个活动,这个类还有其他类对象。我怎样才能做到这一点 下面是该类的代码: //要将其Arraylist发送到其他活动的类。 //这个类在JAR中 public class MacroConfig implements IConfig, IData { private MacroIdentifiers identifiers; priv

我有一个Jar文件中的类,它没有实现parcelable,我无法编辑Jar文件。我从服务器获取对象作为响应,需要使用parcelable将其传递给下一个活动,这个类还有其他类对象。我怎样才能做到这一点

下面是该类的代码:

//要将其Arraylist发送到其他活动的类。 //这个类在JAR中

public class MacroConfig implements IConfig, IData {
    private MacroIdentifiers identifiers;
    private ArrayList<MacroRel> relation;
    private ExecutionMode executionMode;
    private ArrayList<RuleConfig> ruleConfig;
    private ArrayList<String> instruction;
    private ArrayList<String> _type_id;
    private String type;
    @JsonAdapter(JsonConverter.class)
    private ArrayList<Extension> extension;
    @JsonAdapter(JsonConverter.class)
    private Expansion expand;

    public MacroConfig() {
    }
公共类宏配置实现IConfig、IData{
专用宏标识符;
私人ArrayList关系;
私有执行模式执行模式;
私有ArrayList规则配置;
私有数组列表指令;
私有数组列表_type_id;
私有字符串类型;
@JsonAdapter(JsonConverter.class)
私有ArrayList扩展;
@JsonAdapter(JsonConverter.class)
私人扩张;
公共宏配置(){
}

我尝试了博客上提到的事情和其他Stackoverflow问题,但没有找到任何合适的解决方案。

也许你可以尝试另一种方式,从发件人活动:

intent.putExtra("myObject",new Gson().toJson(listObject));
在创建接收方活动时

List<MyObject> obj = new Gson().fromJson(getIntent().getExtras().getString("myObject"), new TypeToken<List<MyObject>>(){}.getType());
List obj=new Gson().fromJson(getIntent().getExtras().getString(“myObject”),new TypeToken(){}.getType());

“我尝试了博客上提到的东西和其他Stackoverflow问题”…例如…?如果您提到您尝试过的内容,那么它可以防止您的问题被标记为可能的重复项,并且您不能将其转换为JSON字符串吗?为什么您需要Parcelable?感谢您提供的解决方案,但我需要传递一个对象的ArrayList,而不仅仅是一个对象。