Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法解析方法“newInstance”_Java_Android - Fatal编程技术网

Java 无法解析方法“newInstance”

Java 无法解析方法“newInstance”,java,android,Java,Android,我发现以下错误: Cannot resolve method 'newInstance(com.example.ghazalitodo.AddReminderActivity, int, int, boolean) 这是我的代码: public void setTime(View v) { if (mCurrentReminderUri == null) { Toast.makeText(this, "click again on the reminder list t

我发现以下错误:

Cannot resolve method 'newInstance(com.example.ghazalitodo.AddReminderActivity, int, int, boolean)
这是我的代码:

public void setTime(View v) {
    if (mCurrentReminderUri == null) {
        Toast.makeText(this, "click again on the reminder list to set time alarm", Toast.LENGTH_LONG).show();
        return;
    }
    Calendar now = Calendar.getInstance();
    TimePickerDialog tpd = TimePickerDialog.newInstance(this, now.get(Calendar.HOUR_OF_DAY),
            now.get(Calendar.MINUTE), false);
    tpd.setThemeDark(false);
    tpd.show(getFragmentManager(), "Timepickerdialog");
}

// On clicking Date picker
public void setDate(View v) {
    if (mCurrentReminderUri == null) {
        Toast.makeText(this, "click again on the reminder list to set date alarm", Toast.LENGTH_LONG).show();
        return;
    }
    Calendar now = Calendar.getInstance();
    DatePickerDialog dpd = DatePickerDialog.new Instance(this, now.get(Calendar.YEAR),
            now.get(Calendar.MONTH),
            now.get(Calendar.DAY_OF_MONTH)
    );
    dpd.show(getFragmentManager(), "Datepickerdialog");
}

如果我错了,请原谅我。我不熟悉那些观点。但是,我认为您应该使用:

TimePickerDialog tpd = new TimePickerDialog(this, null, 
        now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), false);

让我知道这是否有帮助。否则,我将删除我的答案

编辑

我猜您是从某个扩展了DialogFragment的库中复制了代码。这就是为什么你会有一些冲突

为了使用这些对话框的默认实现使代码正常工作,您可以使用:

public void setTime(View v) {
    if (mCurrentReminderUri == null) {
        Toast.makeText(this, "click again on the reminder list to set time alarm", Toast.LENGTH_LONG).show();
        return;
    }
    Calendar now = Calendar.getInstance();
    TimePickerDialog tpd = new TimePickerDialog(this, null,
            now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), false);
    tpd.show();
}

// On clicking Date picker
public void setDate(View v) {
    if (mCurrentReminderUri == null) {
        Toast.makeText(this, "click again on the reminder list to set date alarm", Toast.LENGTH_LONG).show();
        return;
    }
    Calendar now = Calendar.getInstance();
    DatePickerDialog dpd = new DatePickerDialog (this, null, now.get(Calendar.YEAR),
            now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
    dpd.show();
}

当我添加ur更改时,出现了一个新错误,无法解析:tpd.setmedermarkfalse中的符号“tpd”;tpd.showgetFragmentManager,Timepickerdialog;和:无法应用显示在对话框中:dpd.showgetFragmentManager,Datepickerdial,无法解析方法“SetMedMarkBoolean”
public void setTime(View v) {
    if (mCurrentReminderUri == null) {
        Toast.makeText(this, "click again on the reminder list to set time alarm", Toast.LENGTH_LONG).show();
        return;
    }
    Calendar now = Calendar.getInstance();
    TimePickerDialog tpd = new TimePickerDialog(this, null,
            now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), false);
    tpd.show();
}

// On clicking Date picker
public void setDate(View v) {
    if (mCurrentReminderUri == null) {
        Toast.makeText(this, "click again on the reminder list to set date alarm", Toast.LENGTH_LONG).show();
        return;
    }
    Calendar now = Calendar.getInstance();
    DatePickerDialog dpd = new DatePickerDialog (this, null, now.get(Calendar.YEAR),
            now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
    dpd.show();
}