一些类的领域创造parcelable在安卓 [英] creating parcelable in android from some of the fields of a class

查看:141
本文介绍了一些类的领域创造parcelable在安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的意图从一个活动传递到另一个下列哪些类:

i have the following class which i intent to pass from one activity to another:

public class Ad extends ListItem implements parcelable{
    private String _type;
    private String _recordID;
    private String _line1;
    private String _line2;
    private String _line3;
    private String _line4;
    private String _url;
    private IOnUiNeedToUpdateListener _listener;
    private boolean _notActive = false;
    private String _alertText;
    private Double _longitude;
    private Double _latitude;
}

我想通过这种对象的数组从一个活动到另一个。不过,我并不需要通过所有领域。

i want to pass an array of such objects from one activity to another. however, i do not need to pass all fields.

是有可能仅从所需的字段创建一个包裹,并将其发送?

is it possible to create a parcel only from the desired fields and send it?

推荐答案

这是你的code,它写入包裹和你的code表示读取包裹。所以基本上。你可以写任何你想要的。所有成员的内容的一些内容,没有成员,但其他值用于还原对象的状态等等,等等。

It's your code that writes to Parcel and your code that reads from Parcel. So basically yes. You can write whatever you want. Content of all members, content of some, no members, but other values you use to restore state of the object etc, etc.

这篇关于一些类的领域创造parcelable在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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