我很抱歉,我像傻瓜一样解释...

我的意思是我由于错误而无法编译。




public class PictureBean implements Serializable
{
public enum CCLtype implements Serializable
{
    BY, ND, CO, NN, SA
}

private String picture_rm;
private String picture_url;
private String picture_16_9_url;
private String author;
private String title;
private String description;
private String p_memo;
private String p_original_rate;
private String move_url;
private int like_count;
private int picture_exp_count;
private List<JsonObject> tagList;
private List<JsonObject> categoryList;
private CCLtype ccl;
private String picture_source;
private boolean isUserLiked;
private boolean isUserAdded;


我使用此PictureBean.class在服务器中包含图像数据。

但是当我从活动向活动发送PictureBean数据列表时,如下所示,Eclipse发生错误行。

如何从活动发送PictureBean列表到活动?

'mItems的dataType是PictureBean的列表。

intent.putExtra(CategoryDetailPagerActivity.EXTRA_DATA_CATEGORY_DETAIL_LIST, mItems);

最佳答案

更新:

不要将列表本身作为额外的内容。发送一个包含列表作为唯一成员的类对象,如下所示:

public class SerialObject implements Serializable
{
    private static final long serialVersionUID = -3975620301776205681L;

    public List<PictureBean> myItems;
}

SerialObject sb = new SerialObject();
sb.myItems = mItems;
intent.putExtra(CategoryDetailPagerActivity.EXTRA_DATA_CATEGORY_DETAIL_LIST, sb);


原始答案:

这是您的班级应该如何:

public class PictureBean implements Serializable
{
    private static final long serialVersionUID = 6969933524911660214L;

    public enum CCLtype
    {
        BY, ND, CO, NN, SA
    }

    private String picture_rm;
    private String picture_url;
    private String picture_16_9_url;
    private String author;
    private String title;
    private String description;
    private String p_memo;
    private String p_original_rate;
    private String move_url;
    private int like_count;
    private int picture_exp_count;
    private List<JsonObject> tagList;
    private List<JsonObject> categoryList;
    private CCLtype ccl;
    private String picture_source;
    private boolean isUserLiked;
    private boolean isUserAdded;
}


JsonObject类也是如此。

我相信您不必序列化CCLtype

关于java - 我该如何使它可序列化?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27462742/

10-11 02:56