机器人:问题序列化对象投入的意图 [英] android: problem with Serializable object put into intent

查看:134
本文介绍了机器人:问题序列化对象投入的意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题,一类我想通过把球送入putExtras传入的意图() 它的序列化和code是这样的:

Hi i have problem with a class i want to pass in an intent by putting it into the putExtras() Its serializable and the code looks like this:

public abstract class ObjectA extends ArrayList<ObjectA> implements java.io.Serializable{...}

public class ObjectB extends ObjectA {...}


...
Bundle extras = new Bundle();
extras.putSerializable("blabla", ObjectB);
intent.putExtras(extras);

...

Object y = getIntent().getExtras().get("blabla");

问题是,使得y现在是一个ArrayList,不再是对象B,所以我不能丢.. 如果我改变code到

the problem is, that y now is an ArrayList and no longer an ObjectB so i cant cast it.. if i change the code to

public class ObjectB implements java.io.Serializable {...}

它正常工作

推荐答案

通过在你的类实现两者的java.util.List和java.io.Serializable的你已经触发此的 Android的错误

By implementing both java.util.List and java.io.Serializable in your class you've triggered this android bug.

这篇关于机器人:问题序列化对象投入的意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆