Getter 未关联到任何字段 - 领域
Getter is not associated to any field - Realm
我刚开始使用 Realm 库 并试图在我的 android 应用程序中实现它。刚被困在我试图根据 json response 中特定元素的视图类型来划分 listview 的时候].
我试图用 recycler view
实现这些部分,但问题是我有 2 种视图类型,并且为这些视图类型添加了 headers引起问题。由于 Realm
没有 RecyclerAdapter
的支持,我创建了一个实现,它将使用支持 RecyclerView 的自定义适配器。
所以,虽然我会使用 ListView
并尝试为每个 Object 类型使用一个简单的接口来确定类型,然后插入 Headers 基于组的位置。
出于某种原因,Realm 不允许我在扩展 RealmObject
的 class 中实现接口。
这就是 class 的样子:
import com.google.gson.annotations.SerializedName;
import io.realm.RealmObject;
import io.realm.annotations.Ignore;
import io.realm.annotations.PrimaryKey;
public class TestClass extends RealmObject implements Subjects {
@PrimaryKey
@SerializedName("subjectID")
private String subjectID;
private String subjectDate;
@SerializedName("subjectDescription")
private String subjectDescription;
public String getSubjectID() {
return subjectID;
}
public void setSubjectID(String subjectID) {
this.subjectID = subjectID;
}
public String getSubjectDate() {
return subjectDate;
}
public void setSubjectDate(String subjectDate) {
this.subjectDate = subjectDate;
}
public String getSubjectDescription() {
return subjectDescription;
}
public void setSubjectDescription(String subjectDescription) {
this.subjectDescription = subjectDescription;
}
@Override
public boolean isSubjectA() {
return true;
}
@Override
public boolean isFoo() {
return false;
}
@Override
public boolean isBar() {
return false;
}
}
这是编译错误日志:
Error:(76, 20) error: Getter isSubject is not associated to any field.
Note: Creating DefaultRealmModule
Warning:File for type 'io.realm.DefaultRealmModule' created in the last round will not be subject to annotation processing.
Warning:File for type 'io.realm.DefaultRealmModuleMediator' created in the last round will not be subject to annotation processing.
2 warnings
我不知道为什么抱怨这个问题但它没有编译项目。
我在这里阅读了一些关于这个问题的讨论:link ..显然,有一个关于这个问题的公开讨论,但任何其他帮助将不胜感激..谢谢
你的字段名称有错别字,也不应该有前缀,所以应该是 "subject",而 getter 必须是 isSubject()
@Ignore
private boolean subject = false;
public boolean isSubject() {
return subject;
}
.
我刚开始使用 Realm 库 并试图在我的 android 应用程序中实现它。刚被困在我试图根据 json response 中特定元素的视图类型来划分 listview 的时候].
我试图用 recycler view
实现这些部分,但问题是我有 2 种视图类型,并且为这些视图类型添加了 headers引起问题。由于 Realm
没有 RecyclerAdapter
的支持,我创建了一个实现,它将使用支持 RecyclerView 的自定义适配器。
所以,虽然我会使用 ListView
并尝试为每个 Object 类型使用一个简单的接口来确定类型,然后插入 Headers 基于组的位置。
出于某种原因,Realm 不允许我在扩展 RealmObject
的 class 中实现接口。
这就是 class 的样子:
import com.google.gson.annotations.SerializedName;
import io.realm.RealmObject;
import io.realm.annotations.Ignore;
import io.realm.annotations.PrimaryKey;
public class TestClass extends RealmObject implements Subjects {
@PrimaryKey
@SerializedName("subjectID")
private String subjectID;
private String subjectDate;
@SerializedName("subjectDescription")
private String subjectDescription;
public String getSubjectID() {
return subjectID;
}
public void setSubjectID(String subjectID) {
this.subjectID = subjectID;
}
public String getSubjectDate() {
return subjectDate;
}
public void setSubjectDate(String subjectDate) {
this.subjectDate = subjectDate;
}
public String getSubjectDescription() {
return subjectDescription;
}
public void setSubjectDescription(String subjectDescription) {
this.subjectDescription = subjectDescription;
}
@Override
public boolean isSubjectA() {
return true;
}
@Override
public boolean isFoo() {
return false;
}
@Override
public boolean isBar() {
return false;
}
}
这是编译错误日志:
Error:(76, 20) error: Getter isSubject is not associated to any field.
Note: Creating DefaultRealmModule
Warning:File for type 'io.realm.DefaultRealmModule' created in the last round will not be subject to annotation processing.
Warning:File for type 'io.realm.DefaultRealmModuleMediator' created in the last round will not be subject to annotation processing.
2 warnings
我不知道为什么抱怨这个问题但它没有编译项目。
我在这里阅读了一些关于这个问题的讨论:link ..显然,有一个关于这个问题的公开讨论,但任何其他帮助将不胜感激..谢谢
你的字段名称有错别字,也不应该有前缀,所以应该是 "subject",而 getter 必须是 isSubject()
@Ignore
private boolean subject = false;
public boolean isSubject() {
return subject;
}