Android 领域列表<Integer> 和领域列表<String>
Android RealmList<Integer> and RealmList<String>
我正在使用 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;
}
这样我就可以重写我的 class 如下:
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?
不,没有。至少现在还没有。他们是 "working on it":
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
请看一下这个答案 realm 将在 4.0.0 版本中添加对原语的支持
我正在使用 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;
}
这样我就可以重写我的 class 如下:
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?
不,没有。至少现在还没有。他们是 "working on it":
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
请看一下这个答案