gpt4 book ai didi

java - Android RealmList 和 RealmList

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:07:20 25 4
gpt4 key购买 nike

我正在使用 Realm 使用 Realm 创建我的 Android 应用程序的 ORM。问题是当我尝试创建这样的对象时:

public class Airport extends RealmObject {
private int Id;
private String Name;
private String Code;
private RealmList<Integer> destinations;
}

androidStudio 告诉我不能使用 Integer 类型的 RealmList;和 String 类型。我一直在寻找一些类似的问题,但最好的方法是声明一个对象,如:

public class MyRealmInteger extends RealmObject {
private int destination;
}

这样我就可以重写我的类如下:

public class Airport extends RealmObject {
private int Id;
private String Name;
private String Code;
private RealmList<MyRealmInteger> destinations;
}

但我认为这是一个非常复杂的问题。没有其他更简单的解决方案吗?

最佳答案

but I think it's a very complicated. There isn't any other easier solution?

不,没有。至少现在还没有。他们正在“努力”:

This feature is among a handfull of top features that we hope to take on next. We will however give the current 1.0 a bit of peace to ensure stability before we push a lot of new features.

您可以检查此问题以获取更新 https://github.com/realm/realm-java/issues/575

关于java - Android RealmList<Integer> 和 RealmList<String>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37989851/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com