这是我的代码
@Entity(tableName = "tasks")
public final class Task { private static final String TAG =“Task”;
@PrimaryKey
@NonNull
@ColumnInfo(name = "entryId")
private final String mId;
@Nullable
@ColumnInfo(name = "title")
private final String mTitle;
@Nullable
@ColumnInfo(name = "description")
private final String mDescription;
@ColumnInfo(name = "completed")
private final boolean mCompleted;
public Task(@NonNull String Id, @Nullable String Title, @Nullable String Description, boolean Completed) {
mId = Id;
mTitle = Title;
mDescription = Description;
mCompleted = Completed;
}
/**
* 这个构造函数用来创建正在执行的任务
* 新建立的任务不可能马上被完成,
* 所以这里completed = false
*/
@Ignore
public Task(@Nullable String Title, @Nullable String Description) {
this(UUID.randomUUID().toString(), Title, Description, false);
}
/**
* 如果任务已经有了id,那么就创建一个正在执行的任务
* 新建立的任务不可能马上被完成,
* 所以这里completed = false
*/
@Ignore
public Task(@NonNull String Id, @Nullable String Title, @Nullable String Description) {
this(Id, Title, Description, false);
}
/**
* 使用这个构造函数创建一个已完成的任务
*/
@Ignore
public Task(@Nullable String Title, @Nullable String Description, boolean Completed) {
this(UUID.randomUUID().toString(), Title, Description, Completed);
}
@Nullable
public String getDescription() {
return mDescription;
}
@NonNull
public String getId() {
return mId;
}
@Nullable
public String getTitle() {
return mTitle;
}
但我收到了错误,请帮助我,这是谷歌MVP样本 的 github上: https://github.com/googlesamples/android-architecture/tree/todo-mvp/
这是我的错误:
错误:(16,14)错误:实体和Pojos必须具有可用的公共构造函数。您可以拥有一个空构造函数或其参数与字段匹配的构造函数(按名称和类型)。 尝试了以下构造函数,但它们无法匹配: Task(java.lang.String,java.lang.String,java.lang.String,boolean):[Id:null,Title:null,Description:null,Completed:null]
我是新人,请帮助我,非常感谢!!!!