Java androidstudio构造函数错误

Java androidstudio构造函数错误,java,android,constructor,Java,Android,Constructor,我得到一个错误 错误:错误:此片段应提供默认构造函数一个不带参数的公共构造函数com.jdpm.pmn.perfectmaterialnotes.fragments.NoteEditDialogFragment[ValidFragment] 我如何才能更改此设置,使错误消息不会出现 public NoteEditDialogFragment(boolean b) { this.newNote = b; } public static NoteEditDialogFragment new

我得到一个错误

错误:错误:此片段应提供默认构造函数一个不带参数的公共构造函数com.jdpm.pmn.perfectmaterialnotes.fragments.NoteEditDialogFragment[ValidFragment]

我如何才能更改此设置,使错误消息不会出现

public NoteEditDialogFragment(boolean b) {
    this.newNote = b;
}

public static NoteEditDialogFragment newInstance(boolean b) {
    return new NoteEditDialogFragment(b);
}

public static NoteEditDialogFragment newInstance() {
    return new NoteEditDialogFragment(true);
}

添加不带参数的默认构造函数:

public NoteEditDialogFragment() {
    this.newNote = true;
}
这取决于您的应用程序逻辑,您将变量初始化为什么默认值,但由于您在调用newInstance时将newNote设置为true,所以我假设true是一个合理的默认值


嗯,我不知道,也许你应该提供一个默认构造函数一个没有参数的公共构造函数。。。使用带有片段参数的构造函数迟早会让你陷入a**。。。最好改用set/getArguments…错误报告应该更清晰吗?
public NoteEditDialogFragment() {
    this.newNote = true;
}